2007-05-24 17:04:44 -06:00
|
|
|
/*
|
2005-04-16 16:20:36 -06:00
|
|
|
* FiberChannel transport specific attributes exported to sysfs.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved.
|
|
|
|
*
|
|
|
|
* 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) any later version.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
* ========
|
|
|
|
*
|
2007-04-27 10:41:09 -06:00
|
|
|
* Copyright (C) 2004-2007 James Smart, Emulex Corporation
|
2005-04-16 16:20:36 -06:00
|
|
|
* Rewrite for host, target, device, and remote port attributes,
|
|
|
|
* statistics, and service functions...
|
2007-05-24 17:04:44 -06:00
|
|
|
* Add vports, etc
|
2005-04-16 16:20:36 -06:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 02:04:11 -06:00
|
|
|
#include <linux/slab.h>
|
2009-10-30 10:59:29 -06:00
|
|
|
#include <linux/delay.h>
|
2010-08-10 19:01:27 -06:00
|
|
|
#include <linux/kernel.h>
|
2016-11-17 02:31:20 -07:00
|
|
|
#include <linux/bsg-lib.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
#include <scsi/scsi_device.h>
|
|
|
|
#include <scsi/scsi_host.h>
|
|
|
|
#include <scsi/scsi_transport.h>
|
|
|
|
#include <scsi/scsi_transport_fc.h>
|
2006-03-13 06:28:57 -07:00
|
|
|
#include <scsi/scsi_cmnd.h>
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 15:30:09 -06:00
|
|
|
#include <net/netlink.h>
|
|
|
|
#include <scsi/scsi_netlink_fc.h>
|
2009-03-26 11:33:19 -06:00
|
|
|
#include <scsi/scsi_bsg_fc.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
#include "scsi_priv.h"
|
|
|
|
|
2006-04-10 08:14:05 -06:00
|
|
|
static int fc_queue_work(struct Scsi_Host *, struct work_struct *);
|
2007-05-24 17:04:44 -06:00
|
|
|
static void fc_vport_sched_delete(struct work_struct *work);
|
2008-07-18 09:32:52 -06:00
|
|
|
static int fc_vport_setup(struct Scsi_Host *shost, int channel,
|
2007-04-27 10:41:09 -06:00
|
|
|
struct device *pdev, struct fc_vport_identifiers *ids,
|
|
|
|
struct fc_vport **vport);
|
2009-03-26 11:33:19 -06:00
|
|
|
static int fc_bsg_hostadd(struct Scsi_Host *, struct fc_host_attrs *);
|
|
|
|
static int fc_bsg_rportadd(struct Scsi_Host *, struct fc_rport *);
|
|
|
|
static void fc_bsg_remove(struct request_queue *);
|
|
|
|
static void fc_bsg_goose_queue(struct fc_rport *);
|
2007-04-27 10:41:09 -06:00
|
|
|
|
2010-09-15 15:52:32 -06:00
|
|
|
/*
|
|
|
|
* Module Parameters
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dev_loss_tmo: the default number of seconds that the FC transport
|
|
|
|
* should insulate the loss of a remote port.
|
|
|
|
* The maximum will be capped by the value of SCSI_DEVICE_BLOCK_MAX_TIMEOUT.
|
|
|
|
*/
|
|
|
|
static unsigned int fc_dev_loss_tmo = 60; /* seconds */
|
|
|
|
|
|
|
|
module_param_named(dev_loss_tmo, fc_dev_loss_tmo, uint, S_IRUGO|S_IWUSR);
|
|
|
|
MODULE_PARM_DESC(dev_loss_tmo,
|
|
|
|
"Maximum number of seconds that the FC transport should"
|
|
|
|
" insulate the loss of a remote port. Once this value is"
|
|
|
|
" exceeded, the scsi target is removed. Value should be"
|
|
|
|
" between 1 and SCSI_DEVICE_BLOCK_MAX_TIMEOUT if"
|
|
|
|
" fast_io_fail_tmo is not set.");
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* Redefine so that we can have same named attributes in the
|
|
|
|
* sdev/starget/host objects.
|
|
|
|
*/
|
2008-02-21 16:13:36 -07:00
|
|
|
#define FC_DEVICE_ATTR(_prefix,_name,_mode,_show,_store) \
|
|
|
|
struct device_attribute device_attr_##_prefix##_##_name = \
|
2005-04-16 16:20:36 -06:00
|
|
|
__ATTR(_name,_mode,_show,_store)
|
|
|
|
|
|
|
|
#define fc_enum_name_search(title, table_type, table) \
|
|
|
|
static const char *get_fc_##title##_name(enum table_type table_key) \
|
|
|
|
{ \
|
|
|
|
int i; \
|
|
|
|
char *name = NULL; \
|
|
|
|
\
|
2006-06-08 23:23:48 -06:00
|
|
|
for (i = 0; i < ARRAY_SIZE(table); i++) { \
|
2005-04-16 16:20:36 -06:00
|
|
|
if (table[i].value == table_key) { \
|
|
|
|
name = table[i].name; \
|
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
return name; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define fc_enum_name_match(title, table_type, table) \
|
|
|
|
static int get_fc_##title##_match(const char *table_key, \
|
|
|
|
enum table_type *value) \
|
|
|
|
{ \
|
|
|
|
int i; \
|
|
|
|
\
|
2006-06-08 23:23:48 -06:00
|
|
|
for (i = 0; i < ARRAY_SIZE(table); i++) { \
|
2005-04-16 16:20:36 -06:00
|
|
|
if (strncmp(table_key, table[i].name, \
|
|
|
|
table[i].matchlen) == 0) { \
|
|
|
|
*value = table[i].value; \
|
|
|
|
return 0; /* success */ \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
return 1; /* failure */ \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Convert fc_port_type values to ascii string name */
|
|
|
|
static struct {
|
|
|
|
enum fc_port_type value;
|
|
|
|
char *name;
|
|
|
|
} fc_port_type_names[] = {
|
|
|
|
{ FC_PORTTYPE_UNKNOWN, "Unknown" },
|
|
|
|
{ FC_PORTTYPE_OTHER, "Other" },
|
|
|
|
{ FC_PORTTYPE_NOTPRESENT, "Not Present" },
|
|
|
|
{ FC_PORTTYPE_NPORT, "NPort (fabric via point-to-point)" },
|
|
|
|
{ FC_PORTTYPE_NLPORT, "NLPort (fabric via loop)" },
|
|
|
|
{ FC_PORTTYPE_LPORT, "LPort (private loop)" },
|
2009-01-15 08:51:48 -07:00
|
|
|
{ FC_PORTTYPE_PTP, "Point-To-Point (direct nport connection)" },
|
2007-04-27 10:41:09 -06:00
|
|
|
{ FC_PORTTYPE_NPIV, "NPIV VPORT" },
|
2005-04-16 16:20:36 -06:00
|
|
|
};
|
|
|
|
fc_enum_name_search(port_type, fc_port_type, fc_port_type_names)
|
|
|
|
#define FC_PORTTYPE_MAX_NAMELEN 50
|
|
|
|
|
2007-04-27 10:41:09 -06:00
|
|
|
/* Reuse fc_port_type enum function for vport_type */
|
|
|
|
#define get_fc_vport_type_name get_fc_port_type_name
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 15:30:09 -06:00
|
|
|
/* Convert fc_host_event_code values to ascii string name */
|
|
|
|
static const struct {
|
|
|
|
enum fc_host_event_code value;
|
|
|
|
char *name;
|
|
|
|
} fc_host_event_code_names[] = {
|
|
|
|
{ FCH_EVT_LIP, "lip" },
|
|
|
|
{ FCH_EVT_LINKUP, "link_up" },
|
|
|
|
{ FCH_EVT_LINKDOWN, "link_down" },
|
|
|
|
{ FCH_EVT_LIPRESET, "lip_reset" },
|
|
|
|
{ FCH_EVT_RSCN, "rscn" },
|
|
|
|
{ FCH_EVT_ADAPTER_CHANGE, "adapter_chg" },
|
|
|
|
{ FCH_EVT_PORT_UNKNOWN, "port_unknown" },
|
|
|
|
{ FCH_EVT_PORT_ONLINE, "port_online" },
|
|
|
|
{ FCH_EVT_PORT_OFFLINE, "port_offline" },
|
|
|
|
{ FCH_EVT_PORT_FABRIC, "port_fabric" },
|
|
|
|
{ FCH_EVT_LINK_UNKNOWN, "link_unknown" },
|
|
|
|
{ FCH_EVT_VENDOR_UNIQUE, "vendor_unique" },
|
|
|
|
};
|
|
|
|
fc_enum_name_search(host_event_code, fc_host_event_code,
|
|
|
|
fc_host_event_code_names)
|
|
|
|
#define FC_HOST_EVENT_CODE_MAX_NAMELEN 30
|
|
|
|
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/* Convert fc_port_state values to ascii string name */
|
|
|
|
static struct {
|
|
|
|
enum fc_port_state value;
|
|
|
|
char *name;
|
|
|
|
} fc_port_state_names[] = {
|
|
|
|
{ FC_PORTSTATE_UNKNOWN, "Unknown" },
|
|
|
|
{ FC_PORTSTATE_NOTPRESENT, "Not Present" },
|
|
|
|
{ FC_PORTSTATE_ONLINE, "Online" },
|
|
|
|
{ FC_PORTSTATE_OFFLINE, "Offline" },
|
|
|
|
{ FC_PORTSTATE_BLOCKED, "Blocked" },
|
|
|
|
{ FC_PORTSTATE_BYPASSED, "Bypassed" },
|
|
|
|
{ FC_PORTSTATE_DIAGNOSTICS, "Diagnostics" },
|
|
|
|
{ FC_PORTSTATE_LINKDOWN, "Linkdown" },
|
|
|
|
{ FC_PORTSTATE_ERROR, "Error" },
|
|
|
|
{ FC_PORTSTATE_LOOPBACK, "Loopback" },
|
2005-12-15 07:56:22 -07:00
|
|
|
{ FC_PORTSTATE_DELETED, "Deleted" },
|
2005-04-16 16:20:36 -06:00
|
|
|
};
|
|
|
|
fc_enum_name_search(port_state, fc_port_state, fc_port_state_names)
|
|
|
|
#define FC_PORTSTATE_MAX_NAMELEN 20
|
|
|
|
|
|
|
|
|
2007-04-27 10:41:09 -06:00
|
|
|
/* Convert fc_vport_state values to ascii string name */
|
|
|
|
static struct {
|
|
|
|
enum fc_vport_state value;
|
|
|
|
char *name;
|
|
|
|
} fc_vport_state_names[] = {
|
|
|
|
{ FC_VPORT_UNKNOWN, "Unknown" },
|
|
|
|
{ FC_VPORT_ACTIVE, "Active" },
|
|
|
|
{ FC_VPORT_DISABLED, "Disabled" },
|
|
|
|
{ FC_VPORT_LINKDOWN, "Linkdown" },
|
|
|
|
{ FC_VPORT_INITIALIZING, "Initializing" },
|
|
|
|
{ FC_VPORT_NO_FABRIC_SUPP, "No Fabric Support" },
|
|
|
|
{ FC_VPORT_NO_FABRIC_RSCS, "No Fabric Resources" },
|
|
|
|
{ FC_VPORT_FABRIC_LOGOUT, "Fabric Logout" },
|
|
|
|
{ FC_VPORT_FABRIC_REJ_WWN, "Fabric Rejected WWN" },
|
|
|
|
{ FC_VPORT_FAILED, "VPort Failed" },
|
|
|
|
};
|
|
|
|
fc_enum_name_search(vport_state, fc_vport_state, fc_vport_state_names)
|
|
|
|
#define FC_VPORTSTATE_MAX_NAMELEN 24
|
|
|
|
|
|
|
|
/* Reuse fc_vport_state enum function for vport_last_state */
|
|
|
|
#define get_fc_vport_last_state_name get_fc_vport_state_name
|
|
|
|
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/* Convert fc_tgtid_binding_type values to ascii string name */
|
2005-11-28 08:22:25 -07:00
|
|
|
static const struct {
|
2005-04-16 16:20:36 -06:00
|
|
|
enum fc_tgtid_binding_type value;
|
|
|
|
char *name;
|
|
|
|
int matchlen;
|
|
|
|
} fc_tgtid_binding_type_names[] = {
|
|
|
|
{ FC_TGTID_BIND_NONE, "none", 4 },
|
|
|
|
{ FC_TGTID_BIND_BY_WWPN, "wwpn (World Wide Port Name)", 4 },
|
|
|
|
{ FC_TGTID_BIND_BY_WWNN, "wwnn (World Wide Node Name)", 4 },
|
|
|
|
{ FC_TGTID_BIND_BY_ID, "port_id (FC Address)", 7 },
|
|
|
|
};
|
|
|
|
fc_enum_name_search(tgtid_bind_type, fc_tgtid_binding_type,
|
|
|
|
fc_tgtid_binding_type_names)
|
|
|
|
fc_enum_name_match(tgtid_bind_type, fc_tgtid_binding_type,
|
|
|
|
fc_tgtid_binding_type_names)
|
|
|
|
#define FC_BINDTYPE_MAX_NAMELEN 30
|
|
|
|
|
|
|
|
|
|
|
|
#define fc_bitfield_name_search(title, table) \
|
|
|
|
static ssize_t \
|
|
|
|
get_fc_##title##_names(u32 table_key, char *buf) \
|
|
|
|
{ \
|
|
|
|
char *prefix = ""; \
|
|
|
|
ssize_t len = 0; \
|
|
|
|
int i; \
|
|
|
|
\
|
2006-06-08 23:23:48 -06:00
|
|
|
for (i = 0; i < ARRAY_SIZE(table); i++) { \
|
2005-04-16 16:20:36 -06:00
|
|
|
if (table[i].value & table_key) { \
|
|
|
|
len += sprintf(buf + len, "%s%s", \
|
|
|
|
prefix, table[i].name); \
|
|
|
|
prefix = ", "; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
len += sprintf(buf + len, "\n"); \
|
|
|
|
return len; \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Convert FC_COS bit values to ascii string name */
|
2005-11-28 08:22:25 -07:00
|
|
|
static const struct {
|
2005-04-16 16:20:36 -06:00
|
|
|
u32 value;
|
|
|
|
char *name;
|
|
|
|
} fc_cos_names[] = {
|
|
|
|
{ FC_COS_CLASS1, "Class 1" },
|
|
|
|
{ FC_COS_CLASS2, "Class 2" },
|
|
|
|
{ FC_COS_CLASS3, "Class 3" },
|
|
|
|
{ FC_COS_CLASS4, "Class 4" },
|
|
|
|
{ FC_COS_CLASS6, "Class 6" },
|
|
|
|
};
|
|
|
|
fc_bitfield_name_search(cos, fc_cos_names)
|
|
|
|
|
|
|
|
|
|
|
|
/* Convert FC_PORTSPEED bit values to ascii string name */
|
2005-11-28 08:22:25 -07:00
|
|
|
static const struct {
|
2005-04-16 16:20:36 -06:00
|
|
|
u32 value;
|
|
|
|
char *name;
|
|
|
|
} fc_port_speed_names[] = {
|
|
|
|
{ FC_PORTSPEED_1GBIT, "1 Gbit" },
|
|
|
|
{ FC_PORTSPEED_2GBIT, "2 Gbit" },
|
|
|
|
{ FC_PORTSPEED_4GBIT, "4 Gbit" },
|
|
|
|
{ FC_PORTSPEED_10GBIT, "10 Gbit" },
|
2007-03-12 13:16:35 -06:00
|
|
|
{ FC_PORTSPEED_8GBIT, "8 Gbit" },
|
|
|
|
{ FC_PORTSPEED_16GBIT, "16 Gbit" },
|
2014-02-26 02:15:05 -07:00
|
|
|
{ FC_PORTSPEED_32GBIT, "32 Gbit" },
|
2014-06-13 10:40:36 -06:00
|
|
|
{ FC_PORTSPEED_20GBIT, "20 Gbit" },
|
|
|
|
{ FC_PORTSPEED_40GBIT, "40 Gbit" },
|
|
|
|
{ FC_PORTSPEED_50GBIT, "50 Gbit" },
|
|
|
|
{ FC_PORTSPEED_100GBIT, "100 Gbit" },
|
2015-04-02 13:50:52 -06:00
|
|
|
{ FC_PORTSPEED_25GBIT, "25 Gbit" },
|
2005-04-16 16:20:36 -06:00
|
|
|
{ FC_PORTSPEED_NOT_NEGOTIATED, "Not Negotiated" },
|
|
|
|
};
|
|
|
|
fc_bitfield_name_search(port_speed, fc_port_speed_names)
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
show_fc_fc4s (char *buf, u8 *fc4_list)
|
|
|
|
{
|
|
|
|
int i, len=0;
|
|
|
|
|
|
|
|
for (i = 0; i < FC_FC4_LIST_SIZE; i++, fc4_list++)
|
|
|
|
len += sprintf(buf + len , "0x%02x ", *fc4_list);
|
|
|
|
len += sprintf(buf + len, "\n");
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-27 10:41:09 -06:00
|
|
|
/* Convert FC_PORT_ROLE bit values to ascii string name */
|
2005-11-28 08:22:25 -07:00
|
|
|
static const struct {
|
2005-04-16 16:20:36 -06:00
|
|
|
u32 value;
|
|
|
|
char *name;
|
2007-04-27 10:41:09 -06:00
|
|
|
} fc_port_role_names[] = {
|
2017-04-17 12:37:45 -06:00
|
|
|
{ FC_PORT_ROLE_FCP_TARGET, "FCP Target" },
|
|
|
|
{ FC_PORT_ROLE_FCP_INITIATOR, "FCP Initiator" },
|
|
|
|
{ FC_PORT_ROLE_IP_PORT, "IP Port" },
|
|
|
|
{ FC_PORT_ROLE_FCP_DUMMY_INITIATOR, "FCP Dummy Initiator" },
|
2005-04-16 16:20:36 -06:00
|
|
|
};
|
2007-04-27 10:41:09 -06:00
|
|
|
fc_bitfield_name_search(port_roles, fc_port_role_names)
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Define roles that are specific to port_id. Values are relative to ROLE_MASK.
|
|
|
|
*/
|
|
|
|
#define FC_WELLKNOWN_PORTID_MASK 0xfffff0
|
|
|
|
#define FC_WELLKNOWN_ROLE_MASK 0x00000f
|
|
|
|
#define FC_FPORT_PORTID 0x00000e
|
|
|
|
#define FC_FABCTLR_PORTID 0x00000d
|
|
|
|
#define FC_DIRSRVR_PORTID 0x00000c
|
|
|
|
#define FC_TIMESRVR_PORTID 0x00000b
|
|
|
|
#define FC_MGMTSRVR_PORTID 0x00000a
|
|
|
|
|
|
|
|
|
2006-11-22 07:57:56 -07:00
|
|
|
static void fc_timeout_deleted_rport(struct work_struct *work);
|
|
|
|
static void fc_timeout_fail_rport_io(struct work_struct *work);
|
|
|
|
static void fc_scsi_scan_rport(struct work_struct *work);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Attribute counts pre object type...
|
|
|
|
* Increase these values if you add attributes
|
|
|
|
*/
|
|
|
|
#define FC_STARGET_NUM_ATTRS 3
|
2006-08-18 15:33:29 -06:00
|
|
|
#define FC_RPORT_NUM_ATTRS 10
|
2007-04-27 10:41:09 -06:00
|
|
|
#define FC_VPORT_NUM_ATTRS 9
|
2012-01-22 18:29:50 -07:00
|
|
|
#define FC_HOST_NUM_ATTRS 29
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
struct fc_internal {
|
|
|
|
struct scsi_transport_template t;
|
|
|
|
struct fc_function_template *f;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For attributes : each object has :
|
|
|
|
* An array of the actual attributes structures
|
|
|
|
* An array of null-terminated pointers to the attribute
|
|
|
|
* structures - used for mid-layer interaction.
|
|
|
|
*
|
|
|
|
* The attribute containers for the starget and host are are
|
|
|
|
* part of the midlayer. As the remote port is specific to the
|
|
|
|
* fc transport, we must provide the attribute container.
|
|
|
|
*/
|
2008-02-21 16:13:36 -07:00
|
|
|
struct device_attribute private_starget_attrs[
|
2005-04-16 16:20:36 -06:00
|
|
|
FC_STARGET_NUM_ATTRS];
|
2008-02-21 16:13:36 -07:00
|
|
|
struct device_attribute *starget_attrs[FC_STARGET_NUM_ATTRS + 1];
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2008-02-21 16:13:36 -07:00
|
|
|
struct device_attribute private_host_attrs[FC_HOST_NUM_ATTRS];
|
|
|
|
struct device_attribute *host_attrs[FC_HOST_NUM_ATTRS + 1];
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
struct transport_container rport_attr_cont;
|
2008-02-21 16:13:36 -07:00
|
|
|
struct device_attribute private_rport_attrs[FC_RPORT_NUM_ATTRS];
|
|
|
|
struct device_attribute *rport_attrs[FC_RPORT_NUM_ATTRS + 1];
|
2007-04-27 10:41:09 -06:00
|
|
|
|
|
|
|
struct transport_container vport_attr_cont;
|
2008-02-21 16:13:36 -07:00
|
|
|
struct device_attribute private_vport_attrs[FC_VPORT_NUM_ATTRS];
|
|
|
|
struct device_attribute *vport_attrs[FC_VPORT_NUM_ATTRS + 1];
|
2005-04-16 16:20:36 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
#define to_fc_internal(tmpl) container_of(tmpl, struct fc_internal, t)
|
|
|
|
|
2005-08-14 16:09:01 -06:00
|
|
|
static int fc_target_setup(struct transport_container *tc, struct device *dev,
|
2008-02-21 16:13:36 -07:00
|
|
|
struct device *cdev)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
struct scsi_target *starget = to_scsi_target(dev);
|
|
|
|
struct fc_rport *rport = starget_to_rport(starget);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* if parent is remote port, use values from remote port.
|
|
|
|
* Otherwise, this host uses the fc_transport, but not the
|
|
|
|
* remote port interface. As such, initialize to known non-values.
|
|
|
|
*/
|
|
|
|
if (rport) {
|
|
|
|
fc_starget_node_name(starget) = rport->node_name;
|
|
|
|
fc_starget_port_name(starget) = rport->port_name;
|
|
|
|
fc_starget_port_id(starget) = rport->port_id;
|
|
|
|
} else {
|
|
|
|
fc_starget_node_name(starget) = -1;
|
|
|
|
fc_starget_port_name(starget) = -1;
|
|
|
|
fc_starget_port_id(starget) = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DECLARE_TRANSPORT_CLASS(fc_transport_class,
|
|
|
|
"fc_transport",
|
|
|
|
fc_target_setup,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
2005-08-14 16:09:01 -06:00
|
|
|
static int fc_host_setup(struct transport_container *tc, struct device *dev,
|
2008-02-21 16:13:36 -07:00
|
|
|
struct device *cdev)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = dev_to_shost(dev);
|
2006-04-10 08:14:05 -06:00
|
|
|
struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2007-05-24 17:04:44 -06:00
|
|
|
/*
|
2005-04-16 16:20:36 -06:00
|
|
|
* Set default values easily detected by the midlayer as
|
|
|
|
* failure cases. The scsi lldd is responsible for initializing
|
|
|
|
* all transport attributes to valid values per host.
|
|
|
|
*/
|
2006-04-10 08:14:05 -06:00
|
|
|
fc_host->node_name = -1;
|
|
|
|
fc_host->port_name = -1;
|
|
|
|
fc_host->permanent_port_name = -1;
|
|
|
|
fc_host->supported_classes = FC_COS_UNSPECIFIED;
|
|
|
|
memset(fc_host->supported_fc4s, 0,
|
|
|
|
sizeof(fc_host->supported_fc4s));
|
|
|
|
fc_host->supported_speeds = FC_PORTSPEED_UNKNOWN;
|
|
|
|
fc_host->maxframe_size = -1;
|
2007-04-27 10:41:09 -06:00
|
|
|
fc_host->max_npiv_vports = 0;
|
2006-04-10 08:14:05 -06:00
|
|
|
memset(fc_host->serial_number, 0,
|
|
|
|
sizeof(fc_host->serial_number));
|
2012-01-22 18:29:50 -07:00
|
|
|
memset(fc_host->manufacturer, 0,
|
|
|
|
sizeof(fc_host->manufacturer));
|
|
|
|
memset(fc_host->model, 0,
|
|
|
|
sizeof(fc_host->model));
|
|
|
|
memset(fc_host->model_description, 0,
|
|
|
|
sizeof(fc_host->model_description));
|
|
|
|
memset(fc_host->hardware_version, 0,
|
|
|
|
sizeof(fc_host->hardware_version));
|
|
|
|
memset(fc_host->driver_version, 0,
|
|
|
|
sizeof(fc_host->driver_version));
|
|
|
|
memset(fc_host->firmware_version, 0,
|
|
|
|
sizeof(fc_host->firmware_version));
|
|
|
|
memset(fc_host->optionrom_version, 0,
|
|
|
|
sizeof(fc_host->optionrom_version));
|
2006-04-10 08:14:05 -06:00
|
|
|
|
|
|
|
fc_host->port_id = -1;
|
|
|
|
fc_host->port_type = FC_PORTTYPE_UNKNOWN;
|
|
|
|
fc_host->port_state = FC_PORTSTATE_UNKNOWN;
|
|
|
|
memset(fc_host->active_fc4s, 0,
|
|
|
|
sizeof(fc_host->active_fc4s));
|
|
|
|
fc_host->speed = FC_PORTSPEED_UNKNOWN;
|
|
|
|
fc_host->fabric_name = -1;
|
2006-08-17 06:00:43 -06:00
|
|
|
memset(fc_host->symbolic_name, 0, sizeof(fc_host->symbolic_name));
|
|
|
|
memset(fc_host->system_hostname, 0, sizeof(fc_host->system_hostname));
|
2006-04-10 08:14:05 -06:00
|
|
|
|
|
|
|
fc_host->tgtid_bind_type = FC_TGTID_BIND_BY_WWPN;
|
|
|
|
|
|
|
|
INIT_LIST_HEAD(&fc_host->rports);
|
|
|
|
INIT_LIST_HEAD(&fc_host->rport_bindings);
|
2007-04-27 10:41:09 -06:00
|
|
|
INIT_LIST_HEAD(&fc_host->vports);
|
2006-04-10 08:14:05 -06:00
|
|
|
fc_host->next_rport_number = 0;
|
|
|
|
fc_host->next_target_id = 0;
|
2007-04-27 10:41:09 -06:00
|
|
|
fc_host->next_vport_number = 0;
|
|
|
|
fc_host->npiv_vports_inuse = 0;
|
2006-04-10 08:14:05 -06:00
|
|
|
|
2008-05-01 22:02:41 -06:00
|
|
|
snprintf(fc_host->work_q_name, sizeof(fc_host->work_q_name),
|
|
|
|
"fc_wq_%d", shost->host_no);
|
2013-07-03 16:04:57 -06:00
|
|
|
fc_host->work_q = alloc_workqueue("%s", 0, 0, fc_host->work_q_name);
|
2006-04-10 08:14:05 -06:00
|
|
|
if (!fc_host->work_q)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2010-09-15 15:52:32 -06:00
|
|
|
fc_host->dev_loss_tmo = fc_dev_loss_tmo;
|
2008-05-01 22:02:41 -06:00
|
|
|
snprintf(fc_host->devloss_work_q_name,
|
|
|
|
sizeof(fc_host->devloss_work_q_name),
|
|
|
|
"fc_dl_%d", shost->host_no);
|
2013-07-03 16:04:57 -06:00
|
|
|
fc_host->devloss_work_q = alloc_workqueue("%s", 0, 0,
|
|
|
|
fc_host->devloss_work_q_name);
|
2006-04-10 08:14:05 -06:00
|
|
|
if (!fc_host->devloss_work_q) {
|
|
|
|
destroy_workqueue(fc_host->work_q);
|
|
|
|
fc_host->work_q = NULL;
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2009-03-26 11:33:19 -06:00
|
|
|
fc_bsg_hostadd(shost, fc_host);
|
|
|
|
/* ignore any bsg add error - we just can't do sgio */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fc_host_remove(struct transport_container *tc, struct device *dev,
|
|
|
|
struct device *cdev)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = dev_to_shost(dev);
|
|
|
|
struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
|
|
|
|
|
|
|
|
fc_bsg_remove(fc_host->rqst_q);
|
2005-04-16 16:20:36 -06:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DECLARE_TRANSPORT_CLASS(fc_host_class,
|
|
|
|
"fc_host",
|
|
|
|
fc_host_setup,
|
2009-03-26 11:33:19 -06:00
|
|
|
fc_host_remove,
|
2005-04-16 16:20:36 -06:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup and Remove actions for remote ports are handled
|
|
|
|
* in the service functions below.
|
|
|
|
*/
|
|
|
|
static DECLARE_TRANSPORT_CLASS(fc_rport_class,
|
|
|
|
"fc_remote_ports",
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
2007-04-27 10:41:09 -06:00
|
|
|
/*
|
|
|
|
* Setup and Remove actions for virtual ports are handled
|
|
|
|
* in the service functions below.
|
|
|
|
*/
|
|
|
|
static DECLARE_TRANSPORT_CLASS(fc_vport_class,
|
|
|
|
"fc_vports",
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
2007-11-03 12:30:39 -06:00
|
|
|
/*
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 15:30:09 -06:00
|
|
|
* Netlink Infrastructure
|
2007-11-03 12:30:39 -06:00
|
|
|
*/
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 15:30:09 -06:00
|
|
|
|
|
|
|
static atomic_t fc_event_seq;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fc_get_event_number - Obtain the next sequential FC event number
|
|
|
|
*
|
|
|
|
* Notes:
|
2007-11-03 12:30:39 -06:00
|
|
|
* We could have inlined this, but it would have required fc_event_seq to
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 15:30:09 -06:00
|
|
|
* be exposed. For now, live with the subroutine call.
|
|
|
|
* Atomic used to avoid lock/unlock...
|
2007-11-03 12:30:39 -06:00
|
|
|
*/
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 15:30:09 -06:00
|
|
|
u32
|
|
|
|
fc_get_event_number(void)
|
|
|
|
{
|
|
|
|
return atomic_add_return(1, &fc_event_seq);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(fc_get_event_number);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fc_host_post_event - called to post an even on an fc_host.
|
|
|
|
* @shost: host the event occurred on
|
|
|
|
* @event_number: fc event number obtained from get_fc_event_number()
|
|
|
|
* @event_code: fc_host event being posted
|
|
|
|
* @event_data: 32bits of data for the event being posted
|
|
|
|
*
|
|
|
|
* Notes:
|
|
|
|
* This routine assumes no locks are held on entry.
|
2007-11-03 12:30:39 -06:00
|
|
|
*/
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 15:30:09 -06:00
|
|
|
void
|
|
|
|
fc_host_post_event(struct Scsi_Host *shost, u32 event_number,
|
|
|
|
enum fc_host_event_code event_code, u32 event_data)
|
|
|
|
{
|
|
|
|
struct sk_buff *skb;
|
|
|
|
struct nlmsghdr *nlh;
|
|
|
|
struct fc_nl_event *event;
|
|
|
|
const char *name;
|
2013-03-27 00:53:15 -06:00
|
|
|
u32 len;
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 15:30:09 -06:00
|
|
|
int err;
|
|
|
|
|
|
|
|
if (!scsi_nl_sock) {
|
|
|
|
err = -ENOENT;
|
|
|
|
goto send_fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = FC_NL_MSGALIGN(sizeof(*event));
|
|
|
|
|
2013-03-27 00:53:15 -06:00
|
|
|
skb = nlmsg_new(len, GFP_KERNEL);
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 15:30:09 -06:00
|
|
|
if (!skb) {
|
|
|
|
err = -ENOBUFS;
|
|
|
|
goto send_fail;
|
|
|
|
}
|
|
|
|
|
2013-03-27 00:53:15 -06:00
|
|
|
nlh = nlmsg_put(skb, 0, 0, SCSI_TRANSPORT_MSG, len, 0);
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 15:30:09 -06:00
|
|
|
if (!nlh) {
|
|
|
|
err = -ENOBUFS;
|
|
|
|
goto send_fail_skb;
|
|
|
|
}
|
2013-03-27 00:53:15 -06:00
|
|
|
event = nlmsg_data(nlh);
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 15:30:09 -06:00
|
|
|
|
|
|
|
INIT_SCSI_NL_HDR(&event->snlh, SCSI_NL_TRANSPORT_FC,
|
|
|
|
FC_NL_ASYNC_EVENT, len);
|
|
|
|
event->seconds = get_seconds();
|
|
|
|
event->vendor_id = 0;
|
|
|
|
event->host_no = shost->host_no;
|
|
|
|
event->event_datalen = sizeof(u32); /* bytes */
|
|
|
|
event->event_num = event_number;
|
|
|
|
event->event_code = event_code;
|
|
|
|
event->event_data = event_data;
|
|
|
|
|
netlink: change return-value logic of netlink_broadcast()
Currently, netlink_broadcast() reports errors to the caller if no
messages at all were delivered:
1) If, at least, one message has been delivered correctly, returns 0.
2) Otherwise, if no messages at all were delivered due to skb_clone()
failure, return -ENOBUFS.
3) Otherwise, if there are no listeners, return -ESRCH.
With this patch, the caller knows if the delivery of any of the
messages to the listeners have failed:
1) If it fails to deliver any message (for whatever reason), return
-ENOBUFS.
2) Otherwise, if all messages were delivered OK, returns 0.
3) Otherwise, if no listeners, return -ESRCH.
In the current ctnetlink code and in Netfilter in general, we can add
reliable logging and connection tracking event delivery by dropping the
packets whose events were not successfully delivered over Netlink. Of
course, this option would be settable via /proc as this approach reduces
performance (in terms of filtered connections per seconds by a stateful
firewall) but providing reliable logging and event delivery (for
conntrackd) in return.
This patch also changes some clients of netlink_broadcast() that
may report ENOBUFS errors via printk. This error handling is not
of any help. Instead, the userspace daemons that are listening to
those netlink messages should resync themselves with the kernel-side
if they hit ENOBUFS.
BTW, netlink_broadcast() clients include those that call
cn_netlink_send(), nlmsg_multicast() and genlmsg_multicast() since they
internally call netlink_broadcast() and return its error value.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-02-06 00:56:36 -07:00
|
|
|
nlmsg_multicast(scsi_nl_sock, skb, 0, SCSI_NL_GRP_FC_EVENTS,
|
|
|
|
GFP_KERNEL);
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 15:30:09 -06:00
|
|
|
return;
|
|
|
|
|
|
|
|
send_fail_skb:
|
|
|
|
kfree_skb(skb);
|
|
|
|
send_fail:
|
|
|
|
name = get_fc_host_event_code_name(event_code);
|
|
|
|
printk(KERN_WARNING
|
|
|
|
"%s: Dropped Event : host %d %s data 0x%08x - err %d\n",
|
2008-07-04 00:47:27 -06:00
|
|
|
__func__, shost->host_no,
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 15:30:09 -06:00
|
|
|
(name) ? name : "<unknown>", event_data, err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(fc_host_post_event);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2007-11-03 12:30:39 -06:00
|
|
|
* fc_host_post_vendor_event - called to post a vendor unique event on an fc_host
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 15:30:09 -06:00
|
|
|
* @shost: host the event occurred on
|
|
|
|
* @event_number: fc event number obtained from get_fc_event_number()
|
|
|
|
* @data_len: amount, in bytes, of vendor unique data
|
|
|
|
* @data_buf: pointer to vendor unique data
|
2007-11-03 12:30:39 -06:00
|
|
|
* @vendor_id: Vendor id
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 15:30:09 -06:00
|
|
|
*
|
|
|
|
* Notes:
|
|
|
|
* This routine assumes no locks are held on entry.
|
2007-11-03 12:30:39 -06:00
|
|
|
*/
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 15:30:09 -06:00
|
|
|
void
|
|
|
|
fc_host_post_vendor_event(struct Scsi_Host *shost, u32 event_number,
|
2006-08-22 07:55:23 -06:00
|
|
|
u32 data_len, char * data_buf, u64 vendor_id)
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 15:30:09 -06:00
|
|
|
{
|
|
|
|
struct sk_buff *skb;
|
|
|
|
struct nlmsghdr *nlh;
|
|
|
|
struct fc_nl_event *event;
|
2013-03-27 00:53:15 -06:00
|
|
|
u32 len;
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 15:30:09 -06:00
|
|
|
int err;
|
|
|
|
|
|
|
|
if (!scsi_nl_sock) {
|
|
|
|
err = -ENOENT;
|
|
|
|
goto send_vendor_fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = FC_NL_MSGALIGN(sizeof(*event) + data_len);
|
|
|
|
|
2013-03-27 00:53:15 -06:00
|
|
|
skb = nlmsg_new(len, GFP_KERNEL);
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 15:30:09 -06:00
|
|
|
if (!skb) {
|
|
|
|
err = -ENOBUFS;
|
|
|
|
goto send_vendor_fail;
|
|
|
|
}
|
|
|
|
|
2013-03-27 00:53:15 -06:00
|
|
|
nlh = nlmsg_put(skb, 0, 0, SCSI_TRANSPORT_MSG, len, 0);
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 15:30:09 -06:00
|
|
|
if (!nlh) {
|
|
|
|
err = -ENOBUFS;
|
|
|
|
goto send_vendor_fail_skb;
|
|
|
|
}
|
2013-03-27 00:53:15 -06:00
|
|
|
event = nlmsg_data(nlh);
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 15:30:09 -06:00
|
|
|
|
|
|
|
INIT_SCSI_NL_HDR(&event->snlh, SCSI_NL_TRANSPORT_FC,
|
|
|
|
FC_NL_ASYNC_EVENT, len);
|
|
|
|
event->seconds = get_seconds();
|
|
|
|
event->vendor_id = vendor_id;
|
|
|
|
event->host_no = shost->host_no;
|
|
|
|
event->event_datalen = data_len; /* bytes */
|
|
|
|
event->event_num = event_number;
|
|
|
|
event->event_code = FCH_EVT_VENDOR_UNIQUE;
|
|
|
|
memcpy(&event->event_data, data_buf, data_len);
|
|
|
|
|
netlink: change return-value logic of netlink_broadcast()
Currently, netlink_broadcast() reports errors to the caller if no
messages at all were delivered:
1) If, at least, one message has been delivered correctly, returns 0.
2) Otherwise, if no messages at all were delivered due to skb_clone()
failure, return -ENOBUFS.
3) Otherwise, if there are no listeners, return -ESRCH.
With this patch, the caller knows if the delivery of any of the
messages to the listeners have failed:
1) If it fails to deliver any message (for whatever reason), return
-ENOBUFS.
2) Otherwise, if all messages were delivered OK, returns 0.
3) Otherwise, if no listeners, return -ESRCH.
In the current ctnetlink code and in Netfilter in general, we can add
reliable logging and connection tracking event delivery by dropping the
packets whose events were not successfully delivered over Netlink. Of
course, this option would be settable via /proc as this approach reduces
performance (in terms of filtered connections per seconds by a stateful
firewall) but providing reliable logging and event delivery (for
conntrackd) in return.
This patch also changes some clients of netlink_broadcast() that
may report ENOBUFS errors via printk. This error handling is not
of any help. Instead, the userspace daemons that are listening to
those netlink messages should resync themselves with the kernel-side
if they hit ENOBUFS.
BTW, netlink_broadcast() clients include those that call
cn_netlink_send(), nlmsg_multicast() and genlmsg_multicast() since they
internally call netlink_broadcast() and return its error value.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-02-06 00:56:36 -07:00
|
|
|
nlmsg_multicast(scsi_nl_sock, skb, 0, SCSI_NL_GRP_FC_EVENTS,
|
|
|
|
GFP_KERNEL);
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 15:30:09 -06:00
|
|
|
return;
|
|
|
|
|
|
|
|
send_vendor_fail_skb:
|
|
|
|
kfree_skb(skb);
|
|
|
|
send_vendor_fail:
|
|
|
|
printk(KERN_WARNING
|
|
|
|
"%s: Dropped Event : host %d vendor_unique - err %d\n",
|
2008-07-04 00:47:27 -06:00
|
|
|
__func__, shost->host_no, err);
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 15:30:09 -06:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(fc_host_post_vendor_event);
|
|
|
|
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
static __init int fc_transport_init(void)
|
|
|
|
{
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 15:30:09 -06:00
|
|
|
int error;
|
|
|
|
|
|
|
|
atomic_set(&fc_event_seq, 0);
|
|
|
|
|
|
|
|
error = transport_class_register(&fc_host_class);
|
2007-04-27 10:41:09 -06:00
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
error = transport_class_register(&fc_vport_class);
|
2005-04-16 16:20:36 -06:00
|
|
|
if (error)
|
2009-11-17 20:25:16 -07:00
|
|
|
goto unreg_host_class;
|
2005-04-16 16:20:36 -06:00
|
|
|
error = transport_class_register(&fc_rport_class);
|
|
|
|
if (error)
|
2009-11-17 20:25:16 -07:00
|
|
|
goto unreg_vport_class;
|
|
|
|
error = transport_class_register(&fc_transport_class);
|
|
|
|
if (error)
|
|
|
|
goto unreg_rport_class;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
unreg_rport_class:
|
|
|
|
transport_class_unregister(&fc_rport_class);
|
|
|
|
unreg_vport_class:
|
|
|
|
transport_class_unregister(&fc_vport_class);
|
|
|
|
unreg_host_class:
|
|
|
|
transport_class_unregister(&fc_host_class);
|
|
|
|
return error;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit fc_transport_exit(void)
|
|
|
|
{
|
|
|
|
transport_class_unregister(&fc_transport_class);
|
|
|
|
transport_class_unregister(&fc_rport_class);
|
|
|
|
transport_class_unregister(&fc_host_class);
|
2007-04-27 10:41:09 -06:00
|
|
|
transport_class_unregister(&fc_vport_class);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FC Remote Port Attribute Management
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define fc_rport_show_function(field, format_string, sz, cast) \
|
|
|
|
static ssize_t \
|
2008-02-21 16:13:36 -07:00
|
|
|
show_fc_rport_##field (struct device *dev, \
|
|
|
|
struct device_attribute *attr, char *buf) \
|
2005-04-16 16:20:36 -06:00
|
|
|
{ \
|
2008-02-21 16:13:36 -07:00
|
|
|
struct fc_rport *rport = transport_class_to_rport(dev); \
|
2005-04-16 16:20:36 -06:00
|
|
|
struct Scsi_Host *shost = rport_to_shost(rport); \
|
|
|
|
struct fc_internal *i = to_fc_internal(shost->transportt); \
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
if ((i->f->get_rport_##field) && \
|
|
|
|
!((rport->port_state == FC_PORTSTATE_BLOCKED) || \
|
2005-12-15 07:56:22 -07:00
|
|
|
(rport->port_state == FC_PORTSTATE_DELETED) || \
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
(rport->port_state == FC_PORTSTATE_NOTPRESENT))) \
|
2005-04-16 16:20:36 -06:00
|
|
|
i->f->get_rport_##field(rport); \
|
|
|
|
return snprintf(buf, sz, format_string, cast rport->field); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define fc_rport_store_function(field) \
|
|
|
|
static ssize_t \
|
2008-02-21 16:13:36 -07:00
|
|
|
store_fc_rport_##field(struct device *dev, \
|
|
|
|
struct device_attribute *attr, \
|
|
|
|
const char *buf, size_t count) \
|
2005-04-16 16:20:36 -06:00
|
|
|
{ \
|
|
|
|
int val; \
|
2008-02-21 16:13:36 -07:00
|
|
|
struct fc_rport *rport = transport_class_to_rport(dev); \
|
2005-04-16 16:20:36 -06:00
|
|
|
struct Scsi_Host *shost = rport_to_shost(rport); \
|
|
|
|
struct fc_internal *i = to_fc_internal(shost->transportt); \
|
2006-08-18 15:33:29 -06:00
|
|
|
char *cp; \
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
if ((rport->port_state == FC_PORTSTATE_BLOCKED) || \
|
2005-12-15 07:56:22 -07:00
|
|
|
(rport->port_state == FC_PORTSTATE_DELETED) || \
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
(rport->port_state == FC_PORTSTATE_NOTPRESENT)) \
|
|
|
|
return -EBUSY; \
|
2006-08-18 15:33:29 -06:00
|
|
|
val = simple_strtoul(buf, &cp, 0); \
|
|
|
|
if (*cp && (*cp != '\n')) \
|
|
|
|
return -EINVAL; \
|
2005-04-16 16:20:36 -06:00
|
|
|
i->f->set_rport_##field(rport, val); \
|
|
|
|
return count; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define fc_rport_rd_attr(field, format_string, sz) \
|
|
|
|
fc_rport_show_function(field, format_string, sz, ) \
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(rport, field, S_IRUGO, \
|
2005-04-16 16:20:36 -06:00
|
|
|
show_fc_rport_##field, NULL)
|
|
|
|
|
|
|
|
#define fc_rport_rd_attr_cast(field, format_string, sz, cast) \
|
|
|
|
fc_rport_show_function(field, format_string, sz, (cast)) \
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(rport, field, S_IRUGO, \
|
2005-04-16 16:20:36 -06:00
|
|
|
show_fc_rport_##field, NULL)
|
|
|
|
|
|
|
|
#define fc_rport_rw_attr(field, format_string, sz) \
|
|
|
|
fc_rport_show_function(field, format_string, sz, ) \
|
|
|
|
fc_rport_store_function(field) \
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(rport, field, S_IRUGO | S_IWUSR, \
|
2005-04-16 16:20:36 -06:00
|
|
|
show_fc_rport_##field, \
|
|
|
|
store_fc_rport_##field)
|
|
|
|
|
|
|
|
|
|
|
|
#define fc_private_rport_show_function(field, format_string, sz, cast) \
|
|
|
|
static ssize_t \
|
2008-02-21 16:13:36 -07:00
|
|
|
show_fc_rport_##field (struct device *dev, \
|
|
|
|
struct device_attribute *attr, char *buf) \
|
2005-04-16 16:20:36 -06:00
|
|
|
{ \
|
2008-02-21 16:13:36 -07:00
|
|
|
struct fc_rport *rport = transport_class_to_rport(dev); \
|
2005-04-16 16:20:36 -06:00
|
|
|
return snprintf(buf, sz, format_string, cast rport->field); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define fc_private_rport_rd_attr(field, format_string, sz) \
|
|
|
|
fc_private_rport_show_function(field, format_string, sz, ) \
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(rport, field, S_IRUGO, \
|
2005-04-16 16:20:36 -06:00
|
|
|
show_fc_rport_##field, NULL)
|
|
|
|
|
|
|
|
#define fc_private_rport_rd_attr_cast(field, format_string, sz, cast) \
|
|
|
|
fc_private_rport_show_function(field, format_string, sz, (cast)) \
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(rport, field, S_IRUGO, \
|
2005-04-16 16:20:36 -06:00
|
|
|
show_fc_rport_##field, NULL)
|
|
|
|
|
|
|
|
|
|
|
|
#define fc_private_rport_rd_enum_attr(title, maxlen) \
|
|
|
|
static ssize_t \
|
2008-02-21 16:13:36 -07:00
|
|
|
show_fc_rport_##title (struct device *dev, \
|
|
|
|
struct device_attribute *attr, char *buf) \
|
2005-04-16 16:20:36 -06:00
|
|
|
{ \
|
2008-02-21 16:13:36 -07:00
|
|
|
struct fc_rport *rport = transport_class_to_rport(dev); \
|
2005-04-16 16:20:36 -06:00
|
|
|
const char *name; \
|
|
|
|
name = get_fc_##title##_name(rport->title); \
|
|
|
|
if (!name) \
|
|
|
|
return -EINVAL; \
|
|
|
|
return snprintf(buf, maxlen, "%s\n", name); \
|
|
|
|
} \
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(rport, title, S_IRUGO, \
|
2005-04-16 16:20:36 -06:00
|
|
|
show_fc_rport_##title, NULL)
|
|
|
|
|
|
|
|
|
|
|
|
#define SETUP_RPORT_ATTRIBUTE_RD(field) \
|
2008-02-21 16:13:36 -07:00
|
|
|
i->private_rport_attrs[count] = device_attr_rport_##field; \
|
2005-04-16 16:20:36 -06:00
|
|
|
i->private_rport_attrs[count].attr.mode = S_IRUGO; \
|
|
|
|
i->private_rport_attrs[count].store = NULL; \
|
|
|
|
i->rport_attrs[count] = &i->private_rport_attrs[count]; \
|
|
|
|
if (i->f->show_rport_##field) \
|
|
|
|
count++
|
|
|
|
|
|
|
|
#define SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(field) \
|
2008-02-21 16:13:36 -07:00
|
|
|
i->private_rport_attrs[count] = device_attr_rport_##field; \
|
2005-04-16 16:20:36 -06:00
|
|
|
i->private_rport_attrs[count].attr.mode = S_IRUGO; \
|
|
|
|
i->private_rport_attrs[count].store = NULL; \
|
|
|
|
i->rport_attrs[count] = &i->private_rport_attrs[count]; \
|
|
|
|
count++
|
|
|
|
|
|
|
|
#define SETUP_RPORT_ATTRIBUTE_RW(field) \
|
2008-02-21 16:13:36 -07:00
|
|
|
i->private_rport_attrs[count] = device_attr_rport_##field; \
|
2005-04-16 16:20:36 -06:00
|
|
|
if (!i->f->set_rport_##field) { \
|
|
|
|
i->private_rport_attrs[count].attr.mode = S_IRUGO; \
|
|
|
|
i->private_rport_attrs[count].store = NULL; \
|
|
|
|
} \
|
|
|
|
i->rport_attrs[count] = &i->private_rport_attrs[count]; \
|
|
|
|
if (i->f->show_rport_##field) \
|
|
|
|
count++
|
|
|
|
|
2006-08-18 15:33:29 -06:00
|
|
|
#define SETUP_PRIVATE_RPORT_ATTRIBUTE_RW(field) \
|
|
|
|
{ \
|
2008-02-21 16:13:36 -07:00
|
|
|
i->private_rport_attrs[count] = device_attr_rport_##field; \
|
2006-08-18 15:33:29 -06:00
|
|
|
i->rport_attrs[count] = &i->private_rport_attrs[count]; \
|
|
|
|
count++; \
|
|
|
|
}
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* The FC Transport Remote Port Attributes: */
|
|
|
|
|
|
|
|
/* Fixed Remote Port Attributes */
|
|
|
|
|
|
|
|
fc_private_rport_rd_attr(maxframe_size, "%u bytes\n", 20);
|
|
|
|
|
|
|
|
static ssize_t
|
2008-02-21 16:13:36 -07:00
|
|
|
show_fc_rport_supported_classes (struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2008-02-21 16:13:36 -07:00
|
|
|
struct fc_rport *rport = transport_class_to_rport(dev);
|
2005-04-16 16:20:36 -06:00
|
|
|
if (rport->supported_classes == FC_COS_UNSPECIFIED)
|
|
|
|
return snprintf(buf, 20, "unspecified\n");
|
|
|
|
return get_fc_cos_names(rport->supported_classes, buf);
|
|
|
|
}
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(rport, supported_classes, S_IRUGO,
|
2005-04-16 16:20:36 -06:00
|
|
|
show_fc_rport_supported_classes, NULL);
|
|
|
|
|
|
|
|
/* Dynamic Remote Port Attributes */
|
|
|
|
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
/*
|
|
|
|
* dev_loss_tmo attribute
|
|
|
|
*/
|
2010-09-15 15:52:32 -06:00
|
|
|
static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
|
|
|
|
{
|
|
|
|
char *cp;
|
|
|
|
|
|
|
|
*val = simple_strtoul(buf, &cp, 0);
|
2017-04-14 07:58:02 -06:00
|
|
|
if (*cp && (*cp != '\n'))
|
2010-09-15 15:52:32 -06:00
|
|
|
return -EINVAL;
|
|
|
|
/*
|
|
|
|
* Check for overflow; dev_loss_tmo is u32
|
|
|
|
*/
|
|
|
|
if (*val > UINT_MAX)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fc_rport_set_dev_loss_tmo(struct fc_rport *rport,
|
|
|
|
unsigned long val)
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = rport_to_shost(rport);
|
|
|
|
struct fc_internal *i = to_fc_internal(shost->transportt);
|
2010-09-15 15:52:32 -06:00
|
|
|
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
if ((rport->port_state == FC_PORTSTATE_BLOCKED) ||
|
2005-12-15 07:56:22 -07:00
|
|
|
(rport->port_state == FC_PORTSTATE_DELETED) ||
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
(rport->port_state == FC_PORTSTATE_NOTPRESENT))
|
|
|
|
return -EBUSY;
|
2010-03-09 02:18:48 -07:00
|
|
|
/*
|
|
|
|
* Check for overflow; dev_loss_tmo is u32
|
|
|
|
*/
|
|
|
|
if (val > UINT_MAX)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2009-12-15 01:26:06 -07:00
|
|
|
/*
|
|
|
|
* If fast_io_fail is off we have to cap
|
|
|
|
* dev_loss_tmo at SCSI_DEVICE_BLOCK_MAX_TIMEOUT
|
|
|
|
*/
|
|
|
|
if (rport->fast_io_fail_tmo == -1 &&
|
|
|
|
val > SCSI_DEVICE_BLOCK_MAX_TIMEOUT)
|
|
|
|
return -EINVAL;
|
|
|
|
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
i->f->set_rport_dev_loss_tmo(rport, val);
|
2010-09-15 15:52:32 -06:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
fc_rport_show_function(dev_loss_tmo, "%d\n", 20, )
|
|
|
|
static ssize_t
|
|
|
|
store_fc_rport_dev_loss_tmo(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct fc_rport *rport = transport_class_to_rport(dev);
|
|
|
|
unsigned long val;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = fc_str_to_dev_loss(buf, &val);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
rc = fc_rport_set_dev_loss_tmo(rport, val);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
return count;
|
|
|
|
}
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(rport, dev_loss_tmo, S_IRUGO | S_IWUSR,
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
show_fc_rport_dev_loss_tmo, store_fc_rport_dev_loss_tmo);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
|
|
|
|
/* Private Remote Port Attributes */
|
|
|
|
|
|
|
|
fc_private_rport_rd_attr_cast(node_name, "0x%llx\n", 20, unsigned long long);
|
|
|
|
fc_private_rport_rd_attr_cast(port_name, "0x%llx\n", 20, unsigned long long);
|
|
|
|
fc_private_rport_rd_attr(port_id, "0x%06x\n", 20);
|
|
|
|
|
|
|
|
static ssize_t
|
2008-02-21 16:13:36 -07:00
|
|
|
show_fc_rport_roles (struct device *dev, struct device_attribute *attr,
|
|
|
|
char *buf)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2008-02-21 16:13:36 -07:00
|
|
|
struct fc_rport *rport = transport_class_to_rport(dev);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* identify any roles that are port_id specific */
|
|
|
|
if ((rport->port_id != -1) &&
|
|
|
|
(rport->port_id & FC_WELLKNOWN_PORTID_MASK) ==
|
|
|
|
FC_WELLKNOWN_PORTID_MASK) {
|
|
|
|
switch (rport->port_id & FC_WELLKNOWN_ROLE_MASK) {
|
|
|
|
case FC_FPORT_PORTID:
|
|
|
|
return snprintf(buf, 30, "Fabric Port\n");
|
|
|
|
case FC_FABCTLR_PORTID:
|
|
|
|
return snprintf(buf, 30, "Fabric Controller\n");
|
|
|
|
case FC_DIRSRVR_PORTID:
|
|
|
|
return snprintf(buf, 30, "Directory Server\n");
|
|
|
|
case FC_TIMESRVR_PORTID:
|
|
|
|
return snprintf(buf, 30, "Time Server\n");
|
|
|
|
case FC_MGMTSRVR_PORTID:
|
|
|
|
return snprintf(buf, 30, "Management Server\n");
|
|
|
|
default:
|
|
|
|
return snprintf(buf, 30, "Unknown Fabric Entity\n");
|
|
|
|
}
|
|
|
|
} else {
|
2007-04-27 10:41:09 -06:00
|
|
|
if (rport->roles == FC_PORT_ROLE_UNKNOWN)
|
2005-04-16 16:20:36 -06:00
|
|
|
return snprintf(buf, 20, "unknown\n");
|
2007-04-27 10:41:09 -06:00
|
|
|
return get_fc_port_roles_names(rport->roles, buf);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
}
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(rport, roles, S_IRUGO,
|
2005-04-16 16:20:36 -06:00
|
|
|
show_fc_rport_roles, NULL);
|
|
|
|
|
|
|
|
fc_private_rport_rd_enum_attr(port_state, FC_PORTSTATE_MAX_NAMELEN);
|
|
|
|
fc_private_rport_rd_attr(scsi_target_id, "%d\n", 20);
|
|
|
|
|
2006-08-18 15:33:29 -06:00
|
|
|
/*
|
|
|
|
* fast_io_fail_tmo attribute
|
|
|
|
*/
|
|
|
|
static ssize_t
|
2008-02-21 16:13:36 -07:00
|
|
|
show_fc_rport_fast_io_fail_tmo (struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
2006-08-18 15:33:29 -06:00
|
|
|
{
|
2008-02-21 16:13:36 -07:00
|
|
|
struct fc_rport *rport = transport_class_to_rport(dev);
|
2006-08-18 15:33:29 -06:00
|
|
|
|
|
|
|
if (rport->fast_io_fail_tmo == -1)
|
|
|
|
return snprintf(buf, 5, "off\n");
|
|
|
|
return snprintf(buf, 20, "%d\n", rport->fast_io_fail_tmo);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
2008-02-21 16:13:36 -07:00
|
|
|
store_fc_rport_fast_io_fail_tmo(struct device *dev,
|
|
|
|
struct device_attribute *attr, const char *buf,
|
|
|
|
size_t count)
|
2006-08-18 15:33:29 -06:00
|
|
|
{
|
|
|
|
int val;
|
|
|
|
char *cp;
|
2008-02-21 16:13:36 -07:00
|
|
|
struct fc_rport *rport = transport_class_to_rport(dev);
|
2006-08-18 15:33:29 -06:00
|
|
|
|
|
|
|
if ((rport->port_state == FC_PORTSTATE_BLOCKED) ||
|
|
|
|
(rport->port_state == FC_PORTSTATE_DELETED) ||
|
|
|
|
(rport->port_state == FC_PORTSTATE_NOTPRESENT))
|
|
|
|
return -EBUSY;
|
|
|
|
if (strncmp(buf, "off", 3) == 0)
|
|
|
|
rport->fast_io_fail_tmo = -1;
|
|
|
|
else {
|
|
|
|
val = simple_strtoul(buf, &cp, 0);
|
2009-12-15 01:26:06 -07:00
|
|
|
if ((*cp && (*cp != '\n')) || (val < 0))
|
|
|
|
return -EINVAL;
|
|
|
|
/*
|
|
|
|
* Cap fast_io_fail by dev_loss_tmo or
|
|
|
|
* SCSI_DEVICE_BLOCK_MAX_TIMEOUT.
|
|
|
|
*/
|
|
|
|
if ((val >= rport->dev_loss_tmo) ||
|
|
|
|
(val > SCSI_DEVICE_BLOCK_MAX_TIMEOUT))
|
2006-08-18 15:33:29 -06:00
|
|
|
return -EINVAL;
|
2009-12-15 01:26:06 -07:00
|
|
|
|
2006-08-18 15:33:29 -06:00
|
|
|
rport->fast_io_fail_tmo = val;
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(rport, fast_io_fail_tmo, S_IRUGO | S_IWUSR,
|
2006-08-18 15:33:29 -06:00
|
|
|
show_fc_rport_fast_io_fail_tmo, store_fc_rport_fast_io_fail_tmo);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FC SCSI Target Attribute Management
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note: in the target show function we recognize when the remote
|
2010-06-11 04:16:59 -06:00
|
|
|
* port is in the hierarchy and do not allow the driver to get
|
2005-04-16 16:20:36 -06:00
|
|
|
* involved in sysfs functions. The driver only gets involved if
|
|
|
|
* it's the "old" style that doesn't use rports.
|
|
|
|
*/
|
|
|
|
#define fc_starget_show_function(field, format_string, sz, cast) \
|
|
|
|
static ssize_t \
|
2008-02-21 16:13:36 -07:00
|
|
|
show_fc_starget_##field (struct device *dev, \
|
|
|
|
struct device_attribute *attr, char *buf) \
|
2005-04-16 16:20:36 -06:00
|
|
|
{ \
|
2008-02-21 16:13:36 -07:00
|
|
|
struct scsi_target *starget = transport_class_to_starget(dev); \
|
2005-04-16 16:20:36 -06:00
|
|
|
struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \
|
|
|
|
struct fc_internal *i = to_fc_internal(shost->transportt); \
|
|
|
|
struct fc_rport *rport = starget_to_rport(starget); \
|
|
|
|
if (rport) \
|
|
|
|
fc_starget_##field(starget) = rport->field; \
|
|
|
|
else if (i->f->get_starget_##field) \
|
|
|
|
i->f->get_starget_##field(starget); \
|
|
|
|
return snprintf(buf, sz, format_string, \
|
|
|
|
cast fc_starget_##field(starget)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define fc_starget_rd_attr(field, format_string, sz) \
|
|
|
|
fc_starget_show_function(field, format_string, sz, ) \
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(starget, field, S_IRUGO, \
|
2005-04-16 16:20:36 -06:00
|
|
|
show_fc_starget_##field, NULL)
|
|
|
|
|
|
|
|
#define fc_starget_rd_attr_cast(field, format_string, sz, cast) \
|
|
|
|
fc_starget_show_function(field, format_string, sz, (cast)) \
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(starget, field, S_IRUGO, \
|
2005-04-16 16:20:36 -06:00
|
|
|
show_fc_starget_##field, NULL)
|
|
|
|
|
|
|
|
#define SETUP_STARGET_ATTRIBUTE_RD(field) \
|
2008-02-21 16:13:36 -07:00
|
|
|
i->private_starget_attrs[count] = device_attr_starget_##field; \
|
2005-04-16 16:20:36 -06:00
|
|
|
i->private_starget_attrs[count].attr.mode = S_IRUGO; \
|
|
|
|
i->private_starget_attrs[count].store = NULL; \
|
|
|
|
i->starget_attrs[count] = &i->private_starget_attrs[count]; \
|
|
|
|
if (i->f->show_starget_##field) \
|
|
|
|
count++
|
|
|
|
|
|
|
|
#define SETUP_STARGET_ATTRIBUTE_RW(field) \
|
2008-02-21 16:13:36 -07:00
|
|
|
i->private_starget_attrs[count] = device_attr_starget_##field; \
|
2005-04-16 16:20:36 -06:00
|
|
|
if (!i->f->set_starget_##field) { \
|
|
|
|
i->private_starget_attrs[count].attr.mode = S_IRUGO; \
|
|
|
|
i->private_starget_attrs[count].store = NULL; \
|
|
|
|
} \
|
|
|
|
i->starget_attrs[count] = &i->private_starget_attrs[count]; \
|
|
|
|
if (i->f->show_starget_##field) \
|
|
|
|
count++
|
|
|
|
|
|
|
|
/* The FC Transport SCSI Target Attributes: */
|
|
|
|
fc_starget_rd_attr_cast(node_name, "0x%llx\n", 20, unsigned long long);
|
|
|
|
fc_starget_rd_attr_cast(port_name, "0x%llx\n", 20, unsigned long long);
|
|
|
|
fc_starget_rd_attr(port_id, "0x%06x\n", 20);
|
|
|
|
|
|
|
|
|
2007-04-27 10:41:09 -06:00
|
|
|
/*
|
|
|
|
* FC Virtual Port Attribute Management
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define fc_vport_show_function(field, format_string, sz, cast) \
|
|
|
|
static ssize_t \
|
2008-02-21 16:13:36 -07:00
|
|
|
show_fc_vport_##field (struct device *dev, \
|
|
|
|
struct device_attribute *attr, char *buf) \
|
2007-04-27 10:41:09 -06:00
|
|
|
{ \
|
2008-02-21 16:13:36 -07:00
|
|
|
struct fc_vport *vport = transport_class_to_vport(dev); \
|
2007-04-27 10:41:09 -06:00
|
|
|
struct Scsi_Host *shost = vport_to_shost(vport); \
|
|
|
|
struct fc_internal *i = to_fc_internal(shost->transportt); \
|
|
|
|
if ((i->f->get_vport_##field) && \
|
|
|
|
!(vport->flags & (FC_VPORT_DEL | FC_VPORT_CREATING))) \
|
|
|
|
i->f->get_vport_##field(vport); \
|
|
|
|
return snprintf(buf, sz, format_string, cast vport->field); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define fc_vport_store_function(field) \
|
|
|
|
static ssize_t \
|
2008-02-21 16:13:36 -07:00
|
|
|
store_fc_vport_##field(struct device *dev, \
|
|
|
|
struct device_attribute *attr, \
|
|
|
|
const char *buf, size_t count) \
|
2007-04-27 10:41:09 -06:00
|
|
|
{ \
|
|
|
|
int val; \
|
2008-02-21 16:13:36 -07:00
|
|
|
struct fc_vport *vport = transport_class_to_vport(dev); \
|
2007-04-27 10:41:09 -06:00
|
|
|
struct Scsi_Host *shost = vport_to_shost(vport); \
|
|
|
|
struct fc_internal *i = to_fc_internal(shost->transportt); \
|
|
|
|
char *cp; \
|
|
|
|
if (vport->flags & (FC_VPORT_DEL | FC_VPORT_CREATING)) \
|
|
|
|
return -EBUSY; \
|
|
|
|
val = simple_strtoul(buf, &cp, 0); \
|
|
|
|
if (*cp && (*cp != '\n')) \
|
|
|
|
return -EINVAL; \
|
|
|
|
i->f->set_vport_##field(vport, val); \
|
|
|
|
return count; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define fc_vport_store_str_function(field, slen) \
|
|
|
|
static ssize_t \
|
2008-02-21 16:13:36 -07:00
|
|
|
store_fc_vport_##field(struct device *dev, \
|
|
|
|
struct device_attribute *attr, \
|
|
|
|
const char *buf, size_t count) \
|
2007-04-27 10:41:09 -06:00
|
|
|
{ \
|
2008-02-21 16:13:36 -07:00
|
|
|
struct fc_vport *vport = transport_class_to_vport(dev); \
|
2007-04-27 10:41:09 -06:00
|
|
|
struct Scsi_Host *shost = vport_to_shost(vport); \
|
|
|
|
struct fc_internal *i = to_fc_internal(shost->transportt); \
|
|
|
|
unsigned int cnt=count; \
|
|
|
|
\
|
|
|
|
/* count may include a LF at end of string */ \
|
|
|
|
if (buf[cnt-1] == '\n') \
|
|
|
|
cnt--; \
|
|
|
|
if (cnt > ((slen) - 1)) \
|
|
|
|
return -EINVAL; \
|
|
|
|
memcpy(vport->field, buf, cnt); \
|
|
|
|
i->f->set_vport_##field(vport); \
|
|
|
|
return count; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define fc_vport_rd_attr(field, format_string, sz) \
|
|
|
|
fc_vport_show_function(field, format_string, sz, ) \
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(vport, field, S_IRUGO, \
|
2007-04-27 10:41:09 -06:00
|
|
|
show_fc_vport_##field, NULL)
|
|
|
|
|
|
|
|
#define fc_vport_rd_attr_cast(field, format_string, sz, cast) \
|
|
|
|
fc_vport_show_function(field, format_string, sz, (cast)) \
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(vport, field, S_IRUGO, \
|
2007-04-27 10:41:09 -06:00
|
|
|
show_fc_vport_##field, NULL)
|
|
|
|
|
|
|
|
#define fc_vport_rw_attr(field, format_string, sz) \
|
|
|
|
fc_vport_show_function(field, format_string, sz, ) \
|
|
|
|
fc_vport_store_function(field) \
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(vport, field, S_IRUGO | S_IWUSR, \
|
2007-04-27 10:41:09 -06:00
|
|
|
show_fc_vport_##field, \
|
|
|
|
store_fc_vport_##field)
|
|
|
|
|
|
|
|
#define fc_private_vport_show_function(field, format_string, sz, cast) \
|
|
|
|
static ssize_t \
|
2008-02-21 16:13:36 -07:00
|
|
|
show_fc_vport_##field (struct device *dev, \
|
|
|
|
struct device_attribute *attr, char *buf) \
|
2007-04-27 10:41:09 -06:00
|
|
|
{ \
|
2008-02-21 16:13:36 -07:00
|
|
|
struct fc_vport *vport = transport_class_to_vport(dev); \
|
2007-04-27 10:41:09 -06:00
|
|
|
return snprintf(buf, sz, format_string, cast vport->field); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define fc_private_vport_store_u32_function(field) \
|
|
|
|
static ssize_t \
|
2008-02-21 16:13:36 -07:00
|
|
|
store_fc_vport_##field(struct device *dev, \
|
|
|
|
struct device_attribute *attr, \
|
|
|
|
const char *buf, size_t count) \
|
2007-04-27 10:41:09 -06:00
|
|
|
{ \
|
|
|
|
u32 val; \
|
2008-02-21 16:13:36 -07:00
|
|
|
struct fc_vport *vport = transport_class_to_vport(dev); \
|
2007-04-27 10:41:09 -06:00
|
|
|
char *cp; \
|
|
|
|
if (vport->flags & (FC_VPORT_DEL | FC_VPORT_CREATING)) \
|
|
|
|
return -EBUSY; \
|
|
|
|
val = simple_strtoul(buf, &cp, 0); \
|
|
|
|
if (*cp && (*cp != '\n')) \
|
|
|
|
return -EINVAL; \
|
|
|
|
vport->field = val; \
|
|
|
|
return count; \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define fc_private_vport_rd_attr(field, format_string, sz) \
|
|
|
|
fc_private_vport_show_function(field, format_string, sz, ) \
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(vport, field, S_IRUGO, \
|
2007-04-27 10:41:09 -06:00
|
|
|
show_fc_vport_##field, NULL)
|
|
|
|
|
|
|
|
#define fc_private_vport_rd_attr_cast(field, format_string, sz, cast) \
|
|
|
|
fc_private_vport_show_function(field, format_string, sz, (cast)) \
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(vport, field, S_IRUGO, \
|
2007-04-27 10:41:09 -06:00
|
|
|
show_fc_vport_##field, NULL)
|
|
|
|
|
|
|
|
#define fc_private_vport_rw_u32_attr(field, format_string, sz) \
|
|
|
|
fc_private_vport_show_function(field, format_string, sz, ) \
|
|
|
|
fc_private_vport_store_u32_function(field) \
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(vport, field, S_IRUGO | S_IWUSR, \
|
2007-04-27 10:41:09 -06:00
|
|
|
show_fc_vport_##field, \
|
|
|
|
store_fc_vport_##field)
|
|
|
|
|
|
|
|
|
|
|
|
#define fc_private_vport_rd_enum_attr(title, maxlen) \
|
|
|
|
static ssize_t \
|
2008-02-21 16:13:36 -07:00
|
|
|
show_fc_vport_##title (struct device *dev, \
|
|
|
|
struct device_attribute *attr, \
|
|
|
|
char *buf) \
|
2007-04-27 10:41:09 -06:00
|
|
|
{ \
|
2008-02-21 16:13:36 -07:00
|
|
|
struct fc_vport *vport = transport_class_to_vport(dev); \
|
2007-04-27 10:41:09 -06:00
|
|
|
const char *name; \
|
|
|
|
name = get_fc_##title##_name(vport->title); \
|
|
|
|
if (!name) \
|
|
|
|
return -EINVAL; \
|
|
|
|
return snprintf(buf, maxlen, "%s\n", name); \
|
|
|
|
} \
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(vport, title, S_IRUGO, \
|
2007-04-27 10:41:09 -06:00
|
|
|
show_fc_vport_##title, NULL)
|
|
|
|
|
|
|
|
|
|
|
|
#define SETUP_VPORT_ATTRIBUTE_RD(field) \
|
2008-02-21 16:13:36 -07:00
|
|
|
i->private_vport_attrs[count] = device_attr_vport_##field; \
|
2007-04-27 10:41:09 -06:00
|
|
|
i->private_vport_attrs[count].attr.mode = S_IRUGO; \
|
|
|
|
i->private_vport_attrs[count].store = NULL; \
|
|
|
|
i->vport_attrs[count] = &i->private_vport_attrs[count]; \
|
|
|
|
if (i->f->get_##field) \
|
|
|
|
count++
|
|
|
|
/* NOTE: Above MACRO differs: checks function not show bit */
|
|
|
|
|
|
|
|
#define SETUP_PRIVATE_VPORT_ATTRIBUTE_RD(field) \
|
2008-02-21 16:13:36 -07:00
|
|
|
i->private_vport_attrs[count] = device_attr_vport_##field; \
|
2007-04-27 10:41:09 -06:00
|
|
|
i->private_vport_attrs[count].attr.mode = S_IRUGO; \
|
|
|
|
i->private_vport_attrs[count].store = NULL; \
|
|
|
|
i->vport_attrs[count] = &i->private_vport_attrs[count]; \
|
|
|
|
count++
|
|
|
|
|
|
|
|
#define SETUP_VPORT_ATTRIBUTE_WR(field) \
|
2008-02-21 16:13:36 -07:00
|
|
|
i->private_vport_attrs[count] = device_attr_vport_##field; \
|
2007-04-27 10:41:09 -06:00
|
|
|
i->vport_attrs[count] = &i->private_vport_attrs[count]; \
|
|
|
|
if (i->f->field) \
|
|
|
|
count++
|
|
|
|
/* NOTE: Above MACRO differs: checks function */
|
|
|
|
|
|
|
|
#define SETUP_VPORT_ATTRIBUTE_RW(field) \
|
2008-02-21 16:13:36 -07:00
|
|
|
i->private_vport_attrs[count] = device_attr_vport_##field; \
|
2007-04-27 10:41:09 -06:00
|
|
|
if (!i->f->set_vport_##field) { \
|
|
|
|
i->private_vport_attrs[count].attr.mode = S_IRUGO; \
|
|
|
|
i->private_vport_attrs[count].store = NULL; \
|
|
|
|
} \
|
|
|
|
i->vport_attrs[count] = &i->private_vport_attrs[count]; \
|
|
|
|
count++
|
|
|
|
/* NOTE: Above MACRO differs: does not check show bit */
|
|
|
|
|
|
|
|
#define SETUP_PRIVATE_VPORT_ATTRIBUTE_RW(field) \
|
|
|
|
{ \
|
2008-02-21 16:13:36 -07:00
|
|
|
i->private_vport_attrs[count] = device_attr_vport_##field; \
|
2007-04-27 10:41:09 -06:00
|
|
|
i->vport_attrs[count] = &i->private_vport_attrs[count]; \
|
|
|
|
count++; \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* The FC Transport Virtual Port Attributes: */
|
|
|
|
|
|
|
|
/* Fixed Virtual Port Attributes */
|
|
|
|
|
|
|
|
/* Dynamic Virtual Port Attributes */
|
|
|
|
|
|
|
|
/* Private Virtual Port Attributes */
|
|
|
|
|
|
|
|
fc_private_vport_rd_enum_attr(vport_state, FC_VPORTSTATE_MAX_NAMELEN);
|
|
|
|
fc_private_vport_rd_enum_attr(vport_last_state, FC_VPORTSTATE_MAX_NAMELEN);
|
|
|
|
fc_private_vport_rd_attr_cast(node_name, "0x%llx\n", 20, unsigned long long);
|
|
|
|
fc_private_vport_rd_attr_cast(port_name, "0x%llx\n", 20, unsigned long long);
|
|
|
|
|
|
|
|
static ssize_t
|
2008-02-21 16:13:36 -07:00
|
|
|
show_fc_vport_roles (struct device *dev, struct device_attribute *attr,
|
|
|
|
char *buf)
|
2007-04-27 10:41:09 -06:00
|
|
|
{
|
2008-02-21 16:13:36 -07:00
|
|
|
struct fc_vport *vport = transport_class_to_vport(dev);
|
2007-04-27 10:41:09 -06:00
|
|
|
|
|
|
|
if (vport->roles == FC_PORT_ROLE_UNKNOWN)
|
|
|
|
return snprintf(buf, 20, "unknown\n");
|
|
|
|
return get_fc_port_roles_names(vport->roles, buf);
|
|
|
|
}
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(vport, roles, S_IRUGO, show_fc_vport_roles, NULL);
|
2007-04-27 10:41:09 -06:00
|
|
|
|
|
|
|
fc_private_vport_rd_enum_attr(vport_type, FC_PORTTYPE_MAX_NAMELEN);
|
|
|
|
|
|
|
|
fc_private_vport_show_function(symbolic_name, "%s\n",
|
|
|
|
FC_VPORT_SYMBOLIC_NAMELEN + 1, )
|
|
|
|
fc_vport_store_str_function(symbolic_name, FC_VPORT_SYMBOLIC_NAMELEN)
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(vport, symbolic_name, S_IRUGO | S_IWUSR,
|
2007-04-27 10:41:09 -06:00
|
|
|
show_fc_vport_symbolic_name, store_fc_vport_symbolic_name);
|
|
|
|
|
|
|
|
static ssize_t
|
2008-02-21 16:13:36 -07:00
|
|
|
store_fc_vport_delete(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
2007-04-27 10:41:09 -06:00
|
|
|
{
|
2008-02-21 16:13:36 -07:00
|
|
|
struct fc_vport *vport = transport_class_to_vport(dev);
|
2007-05-24 17:04:44 -06:00
|
|
|
struct Scsi_Host *shost = vport_to_shost(vport);
|
2010-01-21 01:15:32 -07:00
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(shost->host_lock, flags);
|
2017-07-24 04:09:36 -06:00
|
|
|
if (vport->flags & (FC_VPORT_DEL | FC_VPORT_CREATING | FC_VPORT_DELETING)) {
|
2010-01-21 01:15:32 -07:00
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
vport->flags |= FC_VPORT_DELETING;
|
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
2007-04-27 10:41:09 -06:00
|
|
|
|
2007-05-24 17:04:44 -06:00
|
|
|
fc_queue_work(shost, &vport->vport_delete_work);
|
2007-04-27 10:41:09 -06:00
|
|
|
return count;
|
|
|
|
}
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(vport, vport_delete, S_IWUSR,
|
2007-04-27 10:41:09 -06:00
|
|
|
NULL, store_fc_vport_delete);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable/Disable vport
|
|
|
|
* Write "1" to disable, write "0" to enable
|
|
|
|
*/
|
|
|
|
static ssize_t
|
2008-02-21 16:13:36 -07:00
|
|
|
store_fc_vport_disable(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf,
|
2007-04-27 10:41:09 -06:00
|
|
|
size_t count)
|
|
|
|
{
|
2008-02-21 16:13:36 -07:00
|
|
|
struct fc_vport *vport = transport_class_to_vport(dev);
|
2007-04-27 10:41:09 -06:00
|
|
|
struct Scsi_Host *shost = vport_to_shost(vport);
|
|
|
|
struct fc_internal *i = to_fc_internal(shost->transportt);
|
|
|
|
int stat;
|
|
|
|
|
|
|
|
if (vport->flags & (FC_VPORT_DEL | FC_VPORT_CREATING))
|
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
if (*buf == '0') {
|
|
|
|
if (vport->vport_state != FC_VPORT_DISABLED)
|
|
|
|
return -EALREADY;
|
|
|
|
} else if (*buf == '1') {
|
|
|
|
if (vport->vport_state == FC_VPORT_DISABLED)
|
|
|
|
return -EALREADY;
|
|
|
|
} else
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
stat = i->f->vport_disable(vport, ((*buf == '0') ? false : true));
|
|
|
|
return stat ? stat : count;
|
|
|
|
}
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(vport, vport_disable, S_IWUSR,
|
2007-04-27 10:41:09 -06:00
|
|
|
NULL, store_fc_vport_disable);
|
|
|
|
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* Host Attribute Management
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define fc_host_show_function(field, format_string, sz, cast) \
|
|
|
|
static ssize_t \
|
2008-02-21 16:13:36 -07:00
|
|
|
show_fc_host_##field (struct device *dev, \
|
|
|
|
struct device_attribute *attr, char *buf) \
|
2005-04-16 16:20:36 -06:00
|
|
|
{ \
|
2008-02-21 16:13:36 -07:00
|
|
|
struct Scsi_Host *shost = transport_class_to_shost(dev); \
|
2005-04-16 16:20:36 -06:00
|
|
|
struct fc_internal *i = to_fc_internal(shost->transportt); \
|
|
|
|
if (i->f->get_host_##field) \
|
|
|
|
i->f->get_host_##field(shost); \
|
|
|
|
return snprintf(buf, sz, format_string, cast fc_host_##field(shost)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define fc_host_store_function(field) \
|
|
|
|
static ssize_t \
|
2008-02-21 16:13:36 -07:00
|
|
|
store_fc_host_##field(struct device *dev, \
|
|
|
|
struct device_attribute *attr, \
|
|
|
|
const char *buf, size_t count) \
|
2005-04-16 16:20:36 -06:00
|
|
|
{ \
|
|
|
|
int val; \
|
2008-02-21 16:13:36 -07:00
|
|
|
struct Scsi_Host *shost = transport_class_to_shost(dev); \
|
2005-04-16 16:20:36 -06:00
|
|
|
struct fc_internal *i = to_fc_internal(shost->transportt); \
|
2006-08-18 15:33:29 -06:00
|
|
|
char *cp; \
|
2005-04-16 16:20:36 -06:00
|
|
|
\
|
2006-08-18 15:33:29 -06:00
|
|
|
val = simple_strtoul(buf, &cp, 0); \
|
|
|
|
if (*cp && (*cp != '\n')) \
|
|
|
|
return -EINVAL; \
|
2005-04-16 16:20:36 -06:00
|
|
|
i->f->set_host_##field(shost, val); \
|
|
|
|
return count; \
|
|
|
|
}
|
|
|
|
|
2006-08-17 06:00:43 -06:00
|
|
|
#define fc_host_store_str_function(field, slen) \
|
|
|
|
static ssize_t \
|
2008-02-21 16:13:36 -07:00
|
|
|
store_fc_host_##field(struct device *dev, \
|
|
|
|
struct device_attribute *attr, \
|
|
|
|
const char *buf, size_t count) \
|
2006-08-17 06:00:43 -06:00
|
|
|
{ \
|
2008-02-21 16:13:36 -07:00
|
|
|
struct Scsi_Host *shost = transport_class_to_shost(dev); \
|
2006-08-17 06:00:43 -06:00
|
|
|
struct fc_internal *i = to_fc_internal(shost->transportt); \
|
|
|
|
unsigned int cnt=count; \
|
|
|
|
\
|
|
|
|
/* count may include a LF at end of string */ \
|
|
|
|
if (buf[cnt-1] == '\n') \
|
|
|
|
cnt--; \
|
|
|
|
if (cnt > ((slen) - 1)) \
|
|
|
|
return -EINVAL; \
|
|
|
|
memcpy(fc_host_##field(shost), buf, cnt); \
|
|
|
|
i->f->set_host_##field(shost); \
|
|
|
|
return count; \
|
|
|
|
}
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
#define fc_host_rd_attr(field, format_string, sz) \
|
|
|
|
fc_host_show_function(field, format_string, sz, ) \
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(host, field, S_IRUGO, \
|
2005-04-16 16:20:36 -06:00
|
|
|
show_fc_host_##field, NULL)
|
|
|
|
|
|
|
|
#define fc_host_rd_attr_cast(field, format_string, sz, cast) \
|
|
|
|
fc_host_show_function(field, format_string, sz, (cast)) \
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(host, field, S_IRUGO, \
|
2005-04-16 16:20:36 -06:00
|
|
|
show_fc_host_##field, NULL)
|
|
|
|
|
|
|
|
#define fc_host_rw_attr(field, format_string, sz) \
|
|
|
|
fc_host_show_function(field, format_string, sz, ) \
|
|
|
|
fc_host_store_function(field) \
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(host, field, S_IRUGO | S_IWUSR, \
|
2005-04-16 16:20:36 -06:00
|
|
|
show_fc_host_##field, \
|
|
|
|
store_fc_host_##field)
|
|
|
|
|
|
|
|
#define fc_host_rd_enum_attr(title, maxlen) \
|
|
|
|
static ssize_t \
|
2008-02-21 16:13:36 -07:00
|
|
|
show_fc_host_##title (struct device *dev, \
|
|
|
|
struct device_attribute *attr, char *buf) \
|
2005-04-16 16:20:36 -06:00
|
|
|
{ \
|
2008-02-21 16:13:36 -07:00
|
|
|
struct Scsi_Host *shost = transport_class_to_shost(dev); \
|
2005-04-16 16:20:36 -06:00
|
|
|
struct fc_internal *i = to_fc_internal(shost->transportt); \
|
|
|
|
const char *name; \
|
|
|
|
if (i->f->get_host_##title) \
|
|
|
|
i->f->get_host_##title(shost); \
|
|
|
|
name = get_fc_##title##_name(fc_host_##title(shost)); \
|
|
|
|
if (!name) \
|
|
|
|
return -EINVAL; \
|
|
|
|
return snprintf(buf, maxlen, "%s\n", name); \
|
|
|
|
} \
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(host, title, S_IRUGO, show_fc_host_##title, NULL)
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
#define SETUP_HOST_ATTRIBUTE_RD(field) \
|
2008-02-21 16:13:36 -07:00
|
|
|
i->private_host_attrs[count] = device_attr_host_##field; \
|
2005-04-16 16:20:36 -06:00
|
|
|
i->private_host_attrs[count].attr.mode = S_IRUGO; \
|
|
|
|
i->private_host_attrs[count].store = NULL; \
|
|
|
|
i->host_attrs[count] = &i->private_host_attrs[count]; \
|
|
|
|
if (i->f->show_host_##field) \
|
|
|
|
count++
|
|
|
|
|
2007-04-27 10:41:09 -06:00
|
|
|
#define SETUP_HOST_ATTRIBUTE_RD_NS(field) \
|
2008-02-21 16:13:36 -07:00
|
|
|
i->private_host_attrs[count] = device_attr_host_##field; \
|
2007-04-27 10:41:09 -06:00
|
|
|
i->private_host_attrs[count].attr.mode = S_IRUGO; \
|
|
|
|
i->private_host_attrs[count].store = NULL; \
|
|
|
|
i->host_attrs[count] = &i->private_host_attrs[count]; \
|
|
|
|
count++
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
#define SETUP_HOST_ATTRIBUTE_RW(field) \
|
2008-02-21 16:13:36 -07:00
|
|
|
i->private_host_attrs[count] = device_attr_host_##field; \
|
2005-04-16 16:20:36 -06:00
|
|
|
if (!i->f->set_host_##field) { \
|
|
|
|
i->private_host_attrs[count].attr.mode = S_IRUGO; \
|
|
|
|
i->private_host_attrs[count].store = NULL; \
|
|
|
|
} \
|
|
|
|
i->host_attrs[count] = &i->private_host_attrs[count]; \
|
|
|
|
if (i->f->show_host_##field) \
|
|
|
|
count++
|
|
|
|
|
|
|
|
|
|
|
|
#define fc_private_host_show_function(field, format_string, sz, cast) \
|
|
|
|
static ssize_t \
|
2008-02-21 16:13:36 -07:00
|
|
|
show_fc_host_##field (struct device *dev, \
|
|
|
|
struct device_attribute *attr, char *buf) \
|
2005-04-16 16:20:36 -06:00
|
|
|
{ \
|
2008-02-21 16:13:36 -07:00
|
|
|
struct Scsi_Host *shost = transport_class_to_shost(dev); \
|
2005-04-16 16:20:36 -06:00
|
|
|
return snprintf(buf, sz, format_string, cast fc_host_##field(shost)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define fc_private_host_rd_attr(field, format_string, sz) \
|
|
|
|
fc_private_host_show_function(field, format_string, sz, ) \
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(host, field, S_IRUGO, \
|
2005-04-16 16:20:36 -06:00
|
|
|
show_fc_host_##field, NULL)
|
|
|
|
|
|
|
|
#define fc_private_host_rd_attr_cast(field, format_string, sz, cast) \
|
|
|
|
fc_private_host_show_function(field, format_string, sz, (cast)) \
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(host, field, S_IRUGO, \
|
2005-04-16 16:20:36 -06:00
|
|
|
show_fc_host_##field, NULL)
|
|
|
|
|
|
|
|
#define SETUP_PRIVATE_HOST_ATTRIBUTE_RD(field) \
|
2008-02-21 16:13:36 -07:00
|
|
|
i->private_host_attrs[count] = device_attr_host_##field; \
|
2005-04-16 16:20:36 -06:00
|
|
|
i->private_host_attrs[count].attr.mode = S_IRUGO; \
|
|
|
|
i->private_host_attrs[count].store = NULL; \
|
|
|
|
i->host_attrs[count] = &i->private_host_attrs[count]; \
|
|
|
|
count++
|
|
|
|
|
|
|
|
#define SETUP_PRIVATE_HOST_ATTRIBUTE_RW(field) \
|
2005-10-27 17:03:37 -06:00
|
|
|
{ \
|
2008-02-21 16:13:36 -07:00
|
|
|
i->private_host_attrs[count] = device_attr_host_##field; \
|
2005-04-16 16:20:36 -06:00
|
|
|
i->host_attrs[count] = &i->private_host_attrs[count]; \
|
2005-10-27 17:03:37 -06:00
|
|
|
count++; \
|
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
|
|
|
|
/* Fixed Host Attributes */
|
|
|
|
|
|
|
|
static ssize_t
|
2008-02-21 16:13:36 -07:00
|
|
|
show_fc_host_supported_classes (struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2008-02-21 16:13:36 -07:00
|
|
|
struct Scsi_Host *shost = transport_class_to_shost(dev);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
if (fc_host_supported_classes(shost) == FC_COS_UNSPECIFIED)
|
|
|
|
return snprintf(buf, 20, "unspecified\n");
|
|
|
|
|
|
|
|
return get_fc_cos_names(fc_host_supported_classes(shost), buf);
|
|
|
|
}
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(host, supported_classes, S_IRUGO,
|
2005-04-16 16:20:36 -06:00
|
|
|
show_fc_host_supported_classes, NULL);
|
|
|
|
|
|
|
|
static ssize_t
|
2008-02-21 16:13:36 -07:00
|
|
|
show_fc_host_supported_fc4s (struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2008-02-21 16:13:36 -07:00
|
|
|
struct Scsi_Host *shost = transport_class_to_shost(dev);
|
2005-04-16 16:20:36 -06:00
|
|
|
return (ssize_t)show_fc_fc4s(buf, fc_host_supported_fc4s(shost));
|
|
|
|
}
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(host, supported_fc4s, S_IRUGO,
|
2005-04-16 16:20:36 -06:00
|
|
|
show_fc_host_supported_fc4s, NULL);
|
|
|
|
|
|
|
|
static ssize_t
|
2008-02-21 16:13:36 -07:00
|
|
|
show_fc_host_supported_speeds (struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2008-02-21 16:13:36 -07:00
|
|
|
struct Scsi_Host *shost = transport_class_to_shost(dev);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
if (fc_host_supported_speeds(shost) == FC_PORTSPEED_UNKNOWN)
|
|
|
|
return snprintf(buf, 20, "unknown\n");
|
|
|
|
|
|
|
|
return get_fc_port_speed_names(fc_host_supported_speeds(shost), buf);
|
|
|
|
}
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(host, supported_speeds, S_IRUGO,
|
2005-04-16 16:20:36 -06:00
|
|
|
show_fc_host_supported_speeds, NULL);
|
|
|
|
|
|
|
|
|
|
|
|
fc_private_host_rd_attr_cast(node_name, "0x%llx\n", 20, unsigned long long);
|
|
|
|
fc_private_host_rd_attr_cast(port_name, "0x%llx\n", 20, unsigned long long);
|
2006-01-12 18:16:54 -07:00
|
|
|
fc_private_host_rd_attr_cast(permanent_port_name, "0x%llx\n", 20,
|
|
|
|
unsigned long long);
|
2005-04-16 16:20:36 -06:00
|
|
|
fc_private_host_rd_attr(maxframe_size, "%u bytes\n", 20);
|
2007-04-27 10:41:09 -06:00
|
|
|
fc_private_host_rd_attr(max_npiv_vports, "%u\n", 20);
|
2005-04-16 16:20:36 -06:00
|
|
|
fc_private_host_rd_attr(serial_number, "%s\n", (FC_SERIAL_NUMBER_SIZE +1));
|
2012-01-22 18:29:50 -07:00
|
|
|
fc_private_host_rd_attr(manufacturer, "%s\n", FC_SERIAL_NUMBER_SIZE + 1);
|
|
|
|
fc_private_host_rd_attr(model, "%s\n", FC_SYMBOLIC_NAME_SIZE + 1);
|
|
|
|
fc_private_host_rd_attr(model_description, "%s\n", FC_SYMBOLIC_NAME_SIZE + 1);
|
|
|
|
fc_private_host_rd_attr(hardware_version, "%s\n", FC_VERSION_STRING_SIZE + 1);
|
|
|
|
fc_private_host_rd_attr(driver_version, "%s\n", FC_VERSION_STRING_SIZE + 1);
|
|
|
|
fc_private_host_rd_attr(firmware_version, "%s\n", FC_VERSION_STRING_SIZE + 1);
|
|
|
|
fc_private_host_rd_attr(optionrom_version, "%s\n", FC_VERSION_STRING_SIZE + 1);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
|
|
|
|
/* Dynamic Host Attributes */
|
|
|
|
|
|
|
|
static ssize_t
|
2008-02-21 16:13:36 -07:00
|
|
|
show_fc_host_active_fc4s (struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2008-02-21 16:13:36 -07:00
|
|
|
struct Scsi_Host *shost = transport_class_to_shost(dev);
|
2005-04-16 16:20:36 -06:00
|
|
|
struct fc_internal *i = to_fc_internal(shost->transportt);
|
|
|
|
|
|
|
|
if (i->f->get_host_active_fc4s)
|
|
|
|
i->f->get_host_active_fc4s(shost);
|
|
|
|
|
|
|
|
return (ssize_t)show_fc_fc4s(buf, fc_host_active_fc4s(shost));
|
|
|
|
}
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(host, active_fc4s, S_IRUGO,
|
2005-04-16 16:20:36 -06:00
|
|
|
show_fc_host_active_fc4s, NULL);
|
|
|
|
|
|
|
|
static ssize_t
|
2008-02-21 16:13:36 -07:00
|
|
|
show_fc_host_speed (struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2008-02-21 16:13:36 -07:00
|
|
|
struct Scsi_Host *shost = transport_class_to_shost(dev);
|
2005-04-16 16:20:36 -06:00
|
|
|
struct fc_internal *i = to_fc_internal(shost->transportt);
|
|
|
|
|
|
|
|
if (i->f->get_host_speed)
|
|
|
|
i->f->get_host_speed(shost);
|
|
|
|
|
|
|
|
if (fc_host_speed(shost) == FC_PORTSPEED_UNKNOWN)
|
|
|
|
return snprintf(buf, 20, "unknown\n");
|
|
|
|
|
|
|
|
return get_fc_port_speed_names(fc_host_speed(shost), buf);
|
|
|
|
}
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(host, speed, S_IRUGO,
|
2005-04-16 16:20:36 -06:00
|
|
|
show_fc_host_speed, NULL);
|
|
|
|
|
|
|
|
|
|
|
|
fc_host_rd_attr(port_id, "0x%06x\n", 20);
|
|
|
|
fc_host_rd_enum_attr(port_type, FC_PORTTYPE_MAX_NAMELEN);
|
|
|
|
fc_host_rd_enum_attr(port_state, FC_PORTSTATE_MAX_NAMELEN);
|
|
|
|
fc_host_rd_attr_cast(fabric_name, "0x%llx\n", 20, unsigned long long);
|
2006-08-14 06:20:25 -06:00
|
|
|
fc_host_rd_attr(symbolic_name, "%s\n", FC_SYMBOLIC_NAME_SIZE + 1);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2006-08-17 06:00:43 -06:00
|
|
|
fc_private_host_show_function(system_hostname, "%s\n",
|
|
|
|
FC_SYMBOLIC_NAME_SIZE + 1, )
|
|
|
|
fc_host_store_str_function(system_hostname, FC_SYMBOLIC_NAME_SIZE)
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(host, system_hostname, S_IRUGO | S_IWUSR,
|
2006-08-17 06:00:43 -06:00
|
|
|
show_fc_host_system_hostname, store_fc_host_system_hostname);
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Private Host Attributes */
|
|
|
|
|
|
|
|
static ssize_t
|
2008-02-21 16:13:36 -07:00
|
|
|
show_fc_private_host_tgtid_bind_type(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2008-02-21 16:13:36 -07:00
|
|
|
struct Scsi_Host *shost = transport_class_to_shost(dev);
|
2005-04-16 16:20:36 -06:00
|
|
|
const char *name;
|
|
|
|
|
|
|
|
name = get_fc_tgtid_bind_type_name(fc_host_tgtid_bind_type(shost));
|
|
|
|
if (!name)
|
|
|
|
return -EINVAL;
|
|
|
|
return snprintf(buf, FC_BINDTYPE_MAX_NAMELEN, "%s\n", name);
|
|
|
|
}
|
|
|
|
|
2005-10-05 11:50:08 -06:00
|
|
|
#define get_list_head_entry(pos, head, member) \
|
|
|
|
pos = list_entry((head)->next, typeof(*pos), member)
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
static ssize_t
|
2008-02-21 16:13:36 -07:00
|
|
|
store_fc_private_host_tgtid_bind_type(struct device *dev,
|
|
|
|
struct device_attribute *attr, const char *buf, size_t count)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2008-02-21 16:13:36 -07:00
|
|
|
struct Scsi_Host *shost = transport_class_to_shost(dev);
|
2005-10-05 11:50:08 -06:00
|
|
|
struct fc_rport *rport;
|
2005-04-16 16:20:36 -06:00
|
|
|
enum fc_tgtid_binding_type val;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
if (get_fc_tgtid_bind_type_match(buf, &val))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* if changing bind type, purge all unused consistent bindings */
|
|
|
|
if (val != fc_host_tgtid_bind_type(shost)) {
|
|
|
|
spin_lock_irqsave(shost->host_lock, flags);
|
2005-10-05 11:50:08 -06:00
|
|
|
while (!list_empty(&fc_host_rport_bindings(shost))) {
|
|
|
|
get_list_head_entry(rport,
|
|
|
|
&fc_host_rport_bindings(shost), peers);
|
2006-04-10 08:14:05 -06:00
|
|
|
list_del(&rport->peers);
|
|
|
|
rport->port_state = FC_PORTSTATE_DELETED;
|
|
|
|
fc_queue_work(shost, &rport->rport_delete_work);
|
2005-10-05 11:50:08 -06:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
fc_host_tgtid_bind_type(shost) = val;
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(host, tgtid_bind_type, S_IRUGO | S_IWUSR,
|
2005-04-16 16:20:36 -06:00
|
|
|
show_fc_private_host_tgtid_bind_type,
|
|
|
|
store_fc_private_host_tgtid_bind_type);
|
|
|
|
|
2005-10-27 17:03:37 -06:00
|
|
|
static ssize_t
|
2008-02-21 16:13:36 -07:00
|
|
|
store_fc_private_host_issue_lip(struct device *dev,
|
|
|
|
struct device_attribute *attr, const char *buf, size_t count)
|
2005-10-27 17:03:37 -06:00
|
|
|
{
|
2008-02-21 16:13:36 -07:00
|
|
|
struct Scsi_Host *shost = transport_class_to_shost(dev);
|
2005-10-27 17:03:37 -06:00
|
|
|
struct fc_internal *i = to_fc_internal(shost->transportt);
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* ignore any data value written to the attribute */
|
|
|
|
if (i->f->issue_fc_host_lip) {
|
|
|
|
ret = i->f->issue_fc_host_lip(shost);
|
|
|
|
return ret ? ret: count;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(host, issue_lip, S_IWUSR, NULL,
|
2005-10-27 17:03:37 -06:00
|
|
|
store_fc_private_host_issue_lip);
|
|
|
|
|
2010-09-15 15:52:32 -06:00
|
|
|
static ssize_t
|
|
|
|
store_fc_private_host_dev_loss_tmo(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = transport_class_to_shost(dev);
|
|
|
|
struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
|
|
|
|
struct fc_rport *rport;
|
|
|
|
unsigned long val, flags;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = fc_str_to_dev_loss(buf, &val);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
fc_host_dev_loss_tmo(shost) = val;
|
|
|
|
spin_lock_irqsave(shost->host_lock, flags);
|
|
|
|
list_for_each_entry(rport, &fc_host->rports, peers)
|
|
|
|
fc_rport_set_dev_loss_tmo(rport, val);
|
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
|
|
|
return count;
|
|
|
|
}
|
2007-04-27 10:41:09 -06:00
|
|
|
|
2010-09-15 15:52:32 -06:00
|
|
|
fc_private_host_show_function(dev_loss_tmo, "%d\n", 20, );
|
|
|
|
static FC_DEVICE_ATTR(host, dev_loss_tmo, S_IRUGO | S_IWUSR,
|
|
|
|
show_fc_host_dev_loss_tmo,
|
|
|
|
store_fc_private_host_dev_loss_tmo);
|
|
|
|
|
|
|
|
fc_private_host_rd_attr(npiv_vports_inuse, "%u\n", 20);
|
2007-04-27 10:41:09 -06:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* Host Statistics Management
|
|
|
|
*/
|
|
|
|
|
2017-06-21 14:24:39 -06:00
|
|
|
/* Show a given attribute in the statistics group */
|
2005-04-16 16:20:36 -06:00
|
|
|
static ssize_t
|
2008-02-21 16:13:36 -07:00
|
|
|
fc_stat_show(const struct device *dev, char *buf, unsigned long offset)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2008-02-21 16:13:36 -07:00
|
|
|
struct Scsi_Host *shost = transport_class_to_shost(dev);
|
2005-04-16 16:20:36 -06:00
|
|
|
struct fc_internal *i = to_fc_internal(shost->transportt);
|
|
|
|
struct fc_host_statistics *stats;
|
|
|
|
ssize_t ret = -ENOENT;
|
|
|
|
|
|
|
|
if (offset > sizeof(struct fc_host_statistics) ||
|
|
|
|
offset % sizeof(u64) != 0)
|
|
|
|
WARN_ON(1);
|
|
|
|
|
|
|
|
if (i->f->get_fc_host_stats) {
|
|
|
|
stats = (i->f->get_fc_host_stats)(shost);
|
|
|
|
if (stats)
|
|
|
|
ret = snprintf(buf, 20, "0x%llx\n",
|
|
|
|
(unsigned long long)*(u64 *)(((u8 *) stats) + offset));
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* generate a read-only statistics attribute */
|
|
|
|
#define fc_host_statistic(name) \
|
2008-02-21 16:13:36 -07:00
|
|
|
static ssize_t show_fcstat_##name(struct device *cd, \
|
|
|
|
struct device_attribute *attr, \
|
|
|
|
char *buf) \
|
2005-04-16 16:20:36 -06:00
|
|
|
{ \
|
|
|
|
return fc_stat_show(cd, buf, \
|
|
|
|
offsetof(struct fc_host_statistics, name)); \
|
|
|
|
} \
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(host, name, S_IRUGO, show_fcstat_##name, NULL)
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
fc_host_statistic(seconds_since_last_reset);
|
|
|
|
fc_host_statistic(tx_frames);
|
|
|
|
fc_host_statistic(tx_words);
|
|
|
|
fc_host_statistic(rx_frames);
|
|
|
|
fc_host_statistic(rx_words);
|
|
|
|
fc_host_statistic(lip_count);
|
|
|
|
fc_host_statistic(nos_count);
|
|
|
|
fc_host_statistic(error_frames);
|
|
|
|
fc_host_statistic(dumped_frames);
|
|
|
|
fc_host_statistic(link_failure_count);
|
|
|
|
fc_host_statistic(loss_of_sync_count);
|
|
|
|
fc_host_statistic(loss_of_signal_count);
|
|
|
|
fc_host_statistic(prim_seq_protocol_err_count);
|
|
|
|
fc_host_statistic(invalid_tx_word_count);
|
|
|
|
fc_host_statistic(invalid_crc_count);
|
|
|
|
fc_host_statistic(fcp_input_requests);
|
|
|
|
fc_host_statistic(fcp_output_requests);
|
|
|
|
fc_host_statistic(fcp_control_requests);
|
|
|
|
fc_host_statistic(fcp_input_megabytes);
|
|
|
|
fc_host_statistic(fcp_output_megabytes);
|
2012-05-25 11:26:38 -06:00
|
|
|
fc_host_statistic(fcp_packet_alloc_failures);
|
|
|
|
fc_host_statistic(fcp_packet_aborts);
|
|
|
|
fc_host_statistic(fcp_frame_alloc_failures);
|
|
|
|
fc_host_statistic(fc_no_free_exch);
|
|
|
|
fc_host_statistic(fc_no_free_exch_xid);
|
|
|
|
fc_host_statistic(fc_xid_not_found);
|
|
|
|
fc_host_statistic(fc_xid_busy);
|
|
|
|
fc_host_statistic(fc_seq_not_found);
|
|
|
|
fc_host_statistic(fc_non_bls_resp);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
static ssize_t
|
2008-02-21 16:13:36 -07:00
|
|
|
fc_reset_statistics(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2008-02-21 16:13:36 -07:00
|
|
|
struct Scsi_Host *shost = transport_class_to_shost(dev);
|
2005-04-16 16:20:36 -06:00
|
|
|
struct fc_internal *i = to_fc_internal(shost->transportt);
|
|
|
|
|
|
|
|
/* ignore any data value written to the attribute */
|
|
|
|
if (i->f->reset_fc_host_stats) {
|
|
|
|
i->f->reset_fc_host_stats(shost);
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(host, reset_statistics, S_IWUSR, NULL,
|
2005-04-16 16:20:36 -06:00
|
|
|
fc_reset_statistics);
|
|
|
|
|
|
|
|
static struct attribute *fc_statistics_attrs[] = {
|
2008-02-21 16:13:36 -07:00
|
|
|
&device_attr_host_seconds_since_last_reset.attr,
|
|
|
|
&device_attr_host_tx_frames.attr,
|
|
|
|
&device_attr_host_tx_words.attr,
|
|
|
|
&device_attr_host_rx_frames.attr,
|
|
|
|
&device_attr_host_rx_words.attr,
|
|
|
|
&device_attr_host_lip_count.attr,
|
|
|
|
&device_attr_host_nos_count.attr,
|
|
|
|
&device_attr_host_error_frames.attr,
|
|
|
|
&device_attr_host_dumped_frames.attr,
|
|
|
|
&device_attr_host_link_failure_count.attr,
|
|
|
|
&device_attr_host_loss_of_sync_count.attr,
|
|
|
|
&device_attr_host_loss_of_signal_count.attr,
|
|
|
|
&device_attr_host_prim_seq_protocol_err_count.attr,
|
|
|
|
&device_attr_host_invalid_tx_word_count.attr,
|
|
|
|
&device_attr_host_invalid_crc_count.attr,
|
|
|
|
&device_attr_host_fcp_input_requests.attr,
|
|
|
|
&device_attr_host_fcp_output_requests.attr,
|
|
|
|
&device_attr_host_fcp_control_requests.attr,
|
|
|
|
&device_attr_host_fcp_input_megabytes.attr,
|
|
|
|
&device_attr_host_fcp_output_megabytes.attr,
|
2012-05-25 11:26:38 -06:00
|
|
|
&device_attr_host_fcp_packet_alloc_failures.attr,
|
|
|
|
&device_attr_host_fcp_packet_aborts.attr,
|
|
|
|
&device_attr_host_fcp_frame_alloc_failures.attr,
|
|
|
|
&device_attr_host_fc_no_free_exch.attr,
|
|
|
|
&device_attr_host_fc_no_free_exch_xid.attr,
|
|
|
|
&device_attr_host_fc_xid_not_found.attr,
|
|
|
|
&device_attr_host_fc_xid_busy.attr,
|
|
|
|
&device_attr_host_fc_seq_not_found.attr,
|
|
|
|
&device_attr_host_fc_non_bls_resp.attr,
|
2008-02-21 16:13:36 -07:00
|
|
|
&device_attr_host_reset_statistics.attr,
|
2005-04-16 16:20:36 -06:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct attribute_group fc_statistics_group = {
|
|
|
|
.name = "statistics",
|
|
|
|
.attrs = fc_statistics_attrs,
|
|
|
|
};
|
|
|
|
|
2007-04-27 10:41:09 -06:00
|
|
|
|
|
|
|
/* Host Vport Attributes */
|
|
|
|
|
|
|
|
static int
|
|
|
|
fc_parse_wwn(const char *ns, u64 *nm)
|
|
|
|
{
|
|
|
|
unsigned int i, j;
|
|
|
|
u8 wwn[8];
|
|
|
|
|
|
|
|
memset(wwn, 0, sizeof(wwn));
|
|
|
|
|
|
|
|
/* Validate and store the new name */
|
|
|
|
for (i=0, j=0; i < 16; i++) {
|
2010-08-10 19:01:27 -06:00
|
|
|
int value;
|
|
|
|
|
|
|
|
value = hex_to_bin(*ns++);
|
|
|
|
if (value >= 0)
|
|
|
|
j = (j << 4) | value;
|
2007-04-27 10:41:09 -06:00
|
|
|
else
|
|
|
|
return -EINVAL;
|
|
|
|
if (i % 2) {
|
|
|
|
wwn[i/2] = j & 0xff;
|
|
|
|
j = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*nm = wwn_to_u64(wwn);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* "Short-cut" sysfs variable to create a new vport on a FC Host.
|
|
|
|
* Input is a string of the form "<WWPN>:<WWNN>". Other attributes
|
|
|
|
* will default to a NPIV-based FCP_Initiator; The WWNs are specified
|
|
|
|
* as hex characters, and may *not* contain any prefixes (e.g. 0x, x, etc)
|
|
|
|
*/
|
|
|
|
static ssize_t
|
2008-02-21 16:13:36 -07:00
|
|
|
store_fc_host_vport_create(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
2007-04-27 10:41:09 -06:00
|
|
|
{
|
2008-02-21 16:13:36 -07:00
|
|
|
struct Scsi_Host *shost = transport_class_to_shost(dev);
|
2007-04-27 10:41:09 -06:00
|
|
|
struct fc_vport_identifiers vid;
|
|
|
|
struct fc_vport *vport;
|
|
|
|
unsigned int cnt=count;
|
|
|
|
int stat;
|
|
|
|
|
|
|
|
memset(&vid, 0, sizeof(vid));
|
|
|
|
|
|
|
|
/* count may include a LF at end of string */
|
|
|
|
if (buf[cnt-1] == '\n')
|
|
|
|
cnt--;
|
|
|
|
|
|
|
|
/* validate we have enough characters for WWPN */
|
|
|
|
if ((cnt != (16+1+16)) || (buf[16] != ':'))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
stat = fc_parse_wwn(&buf[0], &vid.port_name);
|
|
|
|
if (stat)
|
|
|
|
return stat;
|
|
|
|
|
|
|
|
stat = fc_parse_wwn(&buf[17], &vid.node_name);
|
|
|
|
if (stat)
|
|
|
|
return stat;
|
|
|
|
|
|
|
|
vid.roles = FC_PORT_ROLE_FCP_INITIATOR;
|
|
|
|
vid.vport_type = FC_PORTTYPE_NPIV;
|
|
|
|
/* vid.symbolic_name is already zero/NULL's */
|
|
|
|
vid.disable = false; /* always enabled */
|
|
|
|
|
|
|
|
/* we only allow support on Channel 0 !!! */
|
2008-07-18 09:32:52 -06:00
|
|
|
stat = fc_vport_setup(shost, 0, &shost->shost_gendev, &vid, &vport);
|
2007-04-27 10:41:09 -06:00
|
|
|
return stat ? stat : count;
|
|
|
|
}
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(host, vport_create, S_IWUSR, NULL,
|
2007-04-27 10:41:09 -06:00
|
|
|
store_fc_host_vport_create);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* "Short-cut" sysfs variable to delete a vport on a FC Host.
|
|
|
|
* Vport is identified by a string containing "<WWPN>:<WWNN>".
|
|
|
|
* The WWNs are specified as hex characters, and may *not* contain
|
|
|
|
* any prefixes (e.g. 0x, x, etc)
|
|
|
|
*/
|
|
|
|
static ssize_t
|
2008-02-21 16:13:36 -07:00
|
|
|
store_fc_host_vport_delete(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
2007-04-27 10:41:09 -06:00
|
|
|
{
|
2008-02-21 16:13:36 -07:00
|
|
|
struct Scsi_Host *shost = transport_class_to_shost(dev);
|
2007-04-27 10:41:09 -06:00
|
|
|
struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
|
|
|
|
struct fc_vport *vport;
|
|
|
|
u64 wwpn, wwnn;
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned int cnt=count;
|
|
|
|
int stat, match;
|
|
|
|
|
|
|
|
/* count may include a LF at end of string */
|
|
|
|
if (buf[cnt-1] == '\n')
|
|
|
|
cnt--;
|
|
|
|
|
|
|
|
/* validate we have enough characters for WWPN */
|
|
|
|
if ((cnt != (16+1+16)) || (buf[16] != ':'))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
stat = fc_parse_wwn(&buf[0], &wwpn);
|
|
|
|
if (stat)
|
|
|
|
return stat;
|
|
|
|
|
|
|
|
stat = fc_parse_wwn(&buf[17], &wwnn);
|
|
|
|
if (stat)
|
|
|
|
return stat;
|
|
|
|
|
|
|
|
spin_lock_irqsave(shost->host_lock, flags);
|
|
|
|
match = 0;
|
|
|
|
/* we only allow support on Channel 0 !!! */
|
|
|
|
list_for_each_entry(vport, &fc_host->vports, peers) {
|
|
|
|
if ((vport->channel == 0) &&
|
|
|
|
(vport->port_name == wwpn) && (vport->node_name == wwnn)) {
|
2010-01-21 01:15:32 -07:00
|
|
|
if (vport->flags & (FC_VPORT_DEL | FC_VPORT_CREATING))
|
|
|
|
break;
|
|
|
|
vport->flags |= FC_VPORT_DELETING;
|
2007-04-27 10:41:09 -06:00
|
|
|
match = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
|
|
|
|
|
|
|
if (!match)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
stat = fc_vport_terminate(vport);
|
|
|
|
return stat ? stat : count;
|
|
|
|
}
|
2008-02-21 16:13:36 -07:00
|
|
|
static FC_DEVICE_ATTR(host, vport_delete, S_IWUSR, NULL,
|
2007-04-27 10:41:09 -06:00
|
|
|
store_fc_host_vport_delete);
|
|
|
|
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
static int fc_host_match(struct attribute_container *cont,
|
|
|
|
struct device *dev)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost;
|
|
|
|
struct fc_internal *i;
|
|
|
|
|
|
|
|
if (!scsi_is_host_device(dev))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
shost = dev_to_shost(dev);
|
|
|
|
if (!shost->transportt || shost->transportt->host_attrs.ac.class
|
|
|
|
!= &fc_host_class.class)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
i = to_fc_internal(shost->transportt);
|
|
|
|
|
|
|
|
return &i->t.host_attrs.ac == cont;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fc_target_match(struct attribute_container *cont,
|
|
|
|
struct device *dev)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost;
|
|
|
|
struct fc_internal *i;
|
|
|
|
|
|
|
|
if (!scsi_is_target_device(dev))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
shost = dev_to_shost(dev->parent);
|
|
|
|
if (!shost->transportt || shost->transportt->host_attrs.ac.class
|
|
|
|
!= &fc_host_class.class)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
i = to_fc_internal(shost->transportt);
|
|
|
|
|
|
|
|
return &i->t.target_attrs.ac == cont;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void fc_rport_dev_release(struct device *dev)
|
|
|
|
{
|
|
|
|
struct fc_rport *rport = dev_to_rport(dev);
|
|
|
|
put_device(dev->parent);
|
|
|
|
kfree(rport);
|
|
|
|
}
|
|
|
|
|
|
|
|
int scsi_is_fc_rport(const struct device *dev)
|
|
|
|
{
|
|
|
|
return dev->release == fc_rport_dev_release;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(scsi_is_fc_rport);
|
|
|
|
|
|
|
|
static int fc_rport_match(struct attribute_container *cont,
|
|
|
|
struct device *dev)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost;
|
|
|
|
struct fc_internal *i;
|
|
|
|
|
|
|
|
if (!scsi_is_fc_rport(dev))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
shost = dev_to_shost(dev->parent);
|
|
|
|
if (!shost->transportt || shost->transportt->host_attrs.ac.class
|
|
|
|
!= &fc_host_class.class)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
i = to_fc_internal(shost->transportt);
|
|
|
|
|
|
|
|
return &i->rport_attr_cont.ac == cont;
|
|
|
|
}
|
|
|
|
|
2005-06-10 20:24:30 -06:00
|
|
|
|
2007-04-27 10:41:09 -06:00
|
|
|
static void fc_vport_dev_release(struct device *dev)
|
|
|
|
{
|
|
|
|
struct fc_vport *vport = dev_to_vport(dev);
|
|
|
|
put_device(dev->parent); /* release kobj parent */
|
|
|
|
kfree(vport);
|
|
|
|
}
|
|
|
|
|
2016-03-28 15:37:28 -06:00
|
|
|
static int scsi_is_fc_vport(const struct device *dev)
|
2007-04-27 10:41:09 -06:00
|
|
|
{
|
|
|
|
return dev->release == fc_vport_dev_release;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fc_vport_match(struct attribute_container *cont,
|
|
|
|
struct device *dev)
|
|
|
|
{
|
|
|
|
struct fc_vport *vport;
|
|
|
|
struct Scsi_Host *shost;
|
|
|
|
struct fc_internal *i;
|
|
|
|
|
|
|
|
if (!scsi_is_fc_vport(dev))
|
|
|
|
return 0;
|
|
|
|
vport = dev_to_vport(dev);
|
|
|
|
|
|
|
|
shost = vport_to_shost(vport);
|
|
|
|
if (!shost->transportt || shost->transportt->host_attrs.ac.class
|
|
|
|
!= &fc_host_class.class)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
i = to_fc_internal(shost->transportt);
|
|
|
|
return &i->vport_attr_cont.ac == cont;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-13 06:28:57 -07:00
|
|
|
/**
|
2017-01-30 05:18:58 -07:00
|
|
|
* fc_eh_timed_out - FC Transport I/O timeout intercept handler
|
2006-03-13 06:28:57 -07:00
|
|
|
* @scmd: The SCSI command which timed out
|
|
|
|
*
|
|
|
|
* This routine protects against error handlers getting invoked while a
|
|
|
|
* rport is in a blocked state, typically due to a temporarily loss of
|
|
|
|
* connectivity. If the error handlers are allowed to proceed, requests
|
|
|
|
* to abort i/o, reset the target, etc will likely fail as there is no way
|
|
|
|
* to communicate with the device to perform the requested function. These
|
|
|
|
* failures may result in the midlayer taking the device offline, requiring
|
|
|
|
* manual intervention to restore operation.
|
|
|
|
*
|
|
|
|
* This routine, called whenever an i/o times out, validates the state of
|
|
|
|
* the underlying rport. If the rport is blocked, it returns
|
|
|
|
* EH_RESET_TIMER, which will continue to reschedule the timeout.
|
|
|
|
* Eventually, either the device will return, or devloss_tmo will fire,
|
|
|
|
* and when the timeout then fires, it will be handled normally.
|
|
|
|
* If the rport is not blocked, normal error handling continues.
|
|
|
|
*
|
|
|
|
* Notes:
|
|
|
|
* This routine assumes no locks are held on entry.
|
2007-11-03 12:30:39 -06:00
|
|
|
*/
|
2017-01-30 05:18:58 -07:00
|
|
|
enum blk_eh_timer_return
|
|
|
|
fc_eh_timed_out(struct scsi_cmnd *scmd)
|
2006-03-13 06:28:57 -07:00
|
|
|
{
|
|
|
|
struct fc_rport *rport = starget_to_rport(scsi_target(scmd->device));
|
|
|
|
|
|
|
|
if (rport->port_state == FC_PORTSTATE_BLOCKED)
|
2008-09-14 06:55:09 -06:00
|
|
|
return BLK_EH_RESET_TIMER;
|
2006-03-13 06:28:57 -07:00
|
|
|
|
2008-09-14 06:55:09 -06:00
|
|
|
return BLK_EH_NOT_HANDLED;
|
2006-03-13 06:28:57 -07:00
|
|
|
}
|
2017-01-30 05:18:58 -07:00
|
|
|
EXPORT_SYMBOL(fc_eh_timed_out);
|
2006-03-13 06:28:57 -07:00
|
|
|
|
2005-06-10 20:24:30 -06:00
|
|
|
/*
|
2008-04-24 10:12:46 -06:00
|
|
|
* Called by fc_user_scan to locate an rport on the shost that
|
|
|
|
* matches the channel and target id, and invoke scsi_scan_target()
|
|
|
|
* on the rport.
|
2005-06-10 20:24:30 -06:00
|
|
|
*/
|
2008-04-24 10:12:46 -06:00
|
|
|
static void
|
2014-06-25 07:27:36 -06:00
|
|
|
fc_user_scan_tgt(struct Scsi_Host *shost, uint channel, uint id, u64 lun)
|
2005-06-10 20:24:30 -06:00
|
|
|
{
|
|
|
|
struct fc_rport *rport;
|
2008-04-24 10:12:46 -06:00
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(shost->host_lock, flags);
|
2005-06-10 20:24:30 -06:00
|
|
|
|
2006-01-13 11:04:00 -07:00
|
|
|
list_for_each_entry(rport, &fc_host_rports(shost), peers) {
|
|
|
|
if (rport->scsi_target_id == -1)
|
|
|
|
continue;
|
2005-06-10 20:24:30 -06:00
|
|
|
|
2007-06-14 07:16:45 -06:00
|
|
|
if (rport->port_state != FC_PORTSTATE_ONLINE)
|
|
|
|
continue;
|
|
|
|
|
2008-04-24 10:12:46 -06:00
|
|
|
if ((channel == rport->channel) &&
|
|
|
|
(id == rport->scsi_target_id)) {
|
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
2016-03-17 01:39:45 -06:00
|
|
|
scsi_scan_target(&rport->dev, channel, id, lun,
|
|
|
|
SCSI_SCAN_MANUAL);
|
2008-04-24 10:12:46 -06:00
|
|
|
return;
|
2006-01-13 11:04:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-24 10:12:46 -06:00
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Called via sysfs scan routines. Necessary, as the FC transport
|
|
|
|
* wants to place all target objects below the rport object. So this
|
|
|
|
* routine must invoke the scsi_scan_target() routine with the rport
|
|
|
|
* object as the parent.
|
|
|
|
*/
|
|
|
|
static int
|
2014-06-25 07:27:36 -06:00
|
|
|
fc_user_scan(struct Scsi_Host *shost, uint channel, uint id, u64 lun)
|
2008-04-24 10:12:46 -06:00
|
|
|
{
|
|
|
|
uint chlo, chhi;
|
|
|
|
uint tgtlo, tgthi;
|
|
|
|
|
|
|
|
if (((channel != SCAN_WILD_CARD) && (channel > shost->max_channel)) ||
|
|
|
|
((id != SCAN_WILD_CARD) && (id >= shost->max_id)) ||
|
|
|
|
((lun != SCAN_WILD_CARD) && (lun > shost->max_lun)))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (channel == SCAN_WILD_CARD) {
|
|
|
|
chlo = 0;
|
|
|
|
chhi = shost->max_channel + 1;
|
|
|
|
} else {
|
|
|
|
chlo = channel;
|
|
|
|
chhi = channel + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (id == SCAN_WILD_CARD) {
|
|
|
|
tgtlo = 0;
|
|
|
|
tgthi = shost->max_id;
|
|
|
|
} else {
|
|
|
|
tgtlo = id;
|
|
|
|
tgthi = id + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( ; chlo < chhi; chlo++)
|
|
|
|
for ( ; tgtlo < tgthi; tgtlo++)
|
|
|
|
fc_user_scan_tgt(shost, chlo, tgtlo, lun);
|
|
|
|
|
2006-01-13 11:04:00 -07:00
|
|
|
return 0;
|
2005-06-10 20:24:30 -06:00
|
|
|
}
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
struct scsi_transport_template *
|
|
|
|
fc_attach_transport(struct fc_function_template *ft)
|
|
|
|
{
|
|
|
|
int count;
|
2006-01-16 08:31:18 -07:00
|
|
|
struct fc_internal *i = kzalloc(sizeof(struct fc_internal),
|
|
|
|
GFP_KERNEL);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
if (unlikely(!i))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
i->t.target_attrs.ac.attrs = &i->starget_attrs[0];
|
|
|
|
i->t.target_attrs.ac.class = &fc_transport_class.class;
|
|
|
|
i->t.target_attrs.ac.match = fc_target_match;
|
|
|
|
i->t.target_size = sizeof(struct fc_starget_attrs);
|
|
|
|
transport_container_register(&i->t.target_attrs);
|
|
|
|
|
|
|
|
i->t.host_attrs.ac.attrs = &i->host_attrs[0];
|
|
|
|
i->t.host_attrs.ac.class = &fc_host_class.class;
|
|
|
|
i->t.host_attrs.ac.match = fc_host_match;
|
|
|
|
i->t.host_size = sizeof(struct fc_host_attrs);
|
|
|
|
if (ft->get_fc_host_stats)
|
|
|
|
i->t.host_attrs.statistics = &fc_statistics_group;
|
|
|
|
transport_container_register(&i->t.host_attrs);
|
|
|
|
|
|
|
|
i->rport_attr_cont.ac.attrs = &i->rport_attrs[0];
|
|
|
|
i->rport_attr_cont.ac.class = &fc_rport_class.class;
|
|
|
|
i->rport_attr_cont.ac.match = fc_rport_match;
|
|
|
|
transport_container_register(&i->rport_attr_cont);
|
|
|
|
|
2007-04-27 10:41:09 -06:00
|
|
|
i->vport_attr_cont.ac.attrs = &i->vport_attrs[0];
|
|
|
|
i->vport_attr_cont.ac.class = &fc_vport_class.class;
|
|
|
|
i->vport_attr_cont.ac.match = fc_vport_match;
|
|
|
|
transport_container_register(&i->vport_attr_cont);
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
i->f = ft;
|
|
|
|
|
|
|
|
/* Transport uses the shost workq for scsi scanning */
|
|
|
|
i->t.create_work_queue = 1;
|
2005-06-10 20:24:30 -06:00
|
|
|
|
2006-01-13 11:04:00 -07:00
|
|
|
i->t.user_scan = fc_user_scan;
|
2007-05-24 17:04:44 -06:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* Setup SCSI Target Attributes.
|
|
|
|
*/
|
|
|
|
count = 0;
|
|
|
|
SETUP_STARGET_ATTRIBUTE_RD(node_name);
|
|
|
|
SETUP_STARGET_ATTRIBUTE_RD(port_name);
|
|
|
|
SETUP_STARGET_ATTRIBUTE_RD(port_id);
|
|
|
|
|
|
|
|
BUG_ON(count > FC_STARGET_NUM_ATTRS);
|
|
|
|
|
|
|
|
i->starget_attrs[count] = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup SCSI Host Attributes.
|
|
|
|
*/
|
|
|
|
count=0;
|
|
|
|
SETUP_HOST_ATTRIBUTE_RD(node_name);
|
|
|
|
SETUP_HOST_ATTRIBUTE_RD(port_name);
|
2006-01-12 18:16:54 -07:00
|
|
|
SETUP_HOST_ATTRIBUTE_RD(permanent_port_name);
|
2005-04-16 16:20:36 -06:00
|
|
|
SETUP_HOST_ATTRIBUTE_RD(supported_classes);
|
|
|
|
SETUP_HOST_ATTRIBUTE_RD(supported_fc4s);
|
|
|
|
SETUP_HOST_ATTRIBUTE_RD(supported_speeds);
|
|
|
|
SETUP_HOST_ATTRIBUTE_RD(maxframe_size);
|
2007-04-27 10:41:09 -06:00
|
|
|
if (ft->vport_create) {
|
|
|
|
SETUP_HOST_ATTRIBUTE_RD_NS(max_npiv_vports);
|
|
|
|
SETUP_HOST_ATTRIBUTE_RD_NS(npiv_vports_inuse);
|
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
SETUP_HOST_ATTRIBUTE_RD(serial_number);
|
2012-01-22 18:29:50 -07:00
|
|
|
SETUP_HOST_ATTRIBUTE_RD(manufacturer);
|
|
|
|
SETUP_HOST_ATTRIBUTE_RD(model);
|
|
|
|
SETUP_HOST_ATTRIBUTE_RD(model_description);
|
|
|
|
SETUP_HOST_ATTRIBUTE_RD(hardware_version);
|
|
|
|
SETUP_HOST_ATTRIBUTE_RD(driver_version);
|
|
|
|
SETUP_HOST_ATTRIBUTE_RD(firmware_version);
|
|
|
|
SETUP_HOST_ATTRIBUTE_RD(optionrom_version);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
SETUP_HOST_ATTRIBUTE_RD(port_id);
|
|
|
|
SETUP_HOST_ATTRIBUTE_RD(port_type);
|
|
|
|
SETUP_HOST_ATTRIBUTE_RD(port_state);
|
|
|
|
SETUP_HOST_ATTRIBUTE_RD(active_fc4s);
|
|
|
|
SETUP_HOST_ATTRIBUTE_RD(speed);
|
|
|
|
SETUP_HOST_ATTRIBUTE_RD(fabric_name);
|
2006-08-14 06:20:25 -06:00
|
|
|
SETUP_HOST_ATTRIBUTE_RD(symbolic_name);
|
2006-08-17 06:00:43 -06:00
|
|
|
SETUP_HOST_ATTRIBUTE_RW(system_hostname);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Transport-managed attributes */
|
2010-09-15 15:52:32 -06:00
|
|
|
SETUP_PRIVATE_HOST_ATTRIBUTE_RW(dev_loss_tmo);
|
2005-04-16 16:20:36 -06:00
|
|
|
SETUP_PRIVATE_HOST_ATTRIBUTE_RW(tgtid_bind_type);
|
2005-10-27 17:03:37 -06:00
|
|
|
if (ft->issue_fc_host_lip)
|
|
|
|
SETUP_PRIVATE_HOST_ATTRIBUTE_RW(issue_lip);
|
2007-04-27 10:41:09 -06:00
|
|
|
if (ft->vport_create)
|
|
|
|
SETUP_PRIVATE_HOST_ATTRIBUTE_RW(vport_create);
|
|
|
|
if (ft->vport_delete)
|
|
|
|
SETUP_PRIVATE_HOST_ATTRIBUTE_RW(vport_delete);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
BUG_ON(count > FC_HOST_NUM_ATTRS);
|
|
|
|
|
|
|
|
i->host_attrs[count] = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup Remote Port Attributes.
|
|
|
|
*/
|
|
|
|
count=0;
|
|
|
|
SETUP_RPORT_ATTRIBUTE_RD(maxframe_size);
|
|
|
|
SETUP_RPORT_ATTRIBUTE_RD(supported_classes);
|
|
|
|
SETUP_RPORT_ATTRIBUTE_RW(dev_loss_tmo);
|
|
|
|
SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(node_name);
|
|
|
|
SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(port_name);
|
|
|
|
SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(port_id);
|
|
|
|
SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(roles);
|
|
|
|
SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(port_state);
|
|
|
|
SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(scsi_target_id);
|
2008-08-19 17:45:23 -06:00
|
|
|
SETUP_PRIVATE_RPORT_ATTRIBUTE_RW(fast_io_fail_tmo);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
BUG_ON(count > FC_RPORT_NUM_ATTRS);
|
|
|
|
|
|
|
|
i->rport_attrs[count] = NULL;
|
|
|
|
|
2007-04-27 10:41:09 -06:00
|
|
|
/*
|
|
|
|
* Setup Virtual Port Attributes.
|
|
|
|
*/
|
|
|
|
count=0;
|
|
|
|
SETUP_PRIVATE_VPORT_ATTRIBUTE_RD(vport_state);
|
|
|
|
SETUP_PRIVATE_VPORT_ATTRIBUTE_RD(vport_last_state);
|
|
|
|
SETUP_PRIVATE_VPORT_ATTRIBUTE_RD(node_name);
|
|
|
|
SETUP_PRIVATE_VPORT_ATTRIBUTE_RD(port_name);
|
|
|
|
SETUP_PRIVATE_VPORT_ATTRIBUTE_RD(roles);
|
|
|
|
SETUP_PRIVATE_VPORT_ATTRIBUTE_RD(vport_type);
|
|
|
|
SETUP_VPORT_ATTRIBUTE_RW(symbolic_name);
|
|
|
|
SETUP_VPORT_ATTRIBUTE_WR(vport_delete);
|
|
|
|
SETUP_VPORT_ATTRIBUTE_WR(vport_disable);
|
|
|
|
|
|
|
|
BUG_ON(count > FC_VPORT_NUM_ATTRS);
|
|
|
|
|
|
|
|
i->vport_attrs[count] = NULL;
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
return &i->t;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(fc_attach_transport);
|
|
|
|
|
|
|
|
void fc_release_transport(struct scsi_transport_template *t)
|
|
|
|
{
|
|
|
|
struct fc_internal *i = to_fc_internal(t);
|
|
|
|
|
|
|
|
transport_container_unregister(&i->t.target_attrs);
|
|
|
|
transport_container_unregister(&i->t.host_attrs);
|
|
|
|
transport_container_unregister(&i->rport_attr_cont);
|
2007-04-27 10:41:09 -06:00
|
|
|
transport_container_unregister(&i->vport_attr_cont);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
kfree(i);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(fc_release_transport);
|
|
|
|
|
2006-04-10 08:14:05 -06:00
|
|
|
/**
|
|
|
|
* fc_queue_work - Queue work to the fc_host workqueue.
|
|
|
|
* @shost: Pointer to Scsi_Host bound to fc_host.
|
|
|
|
* @work: Work to queue for execution.
|
|
|
|
*
|
|
|
|
* Return value:
|
[SCSI] fc transport: resolve scan vs delete deadlocks
In a prior posting to linux-scsi on the fc transport and workq
deadlocks, we noted a second error that did not have a patch:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114467847711383&w=2
- There's a deadlock where scsi_remove_target() has to sit behind
scsi_scan_target() due to contention over the scan_lock().
Subsequently we posted a request for comments about the deadlock:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114469358829500&w=2
This posting resolves the second error. Here's what we now understand,
and are implementing:
If the lldd deletes the rport while a scan is active, the sdev's queue
is blocked which stops the issuing of commands associated with the scan.
At this point, the scan stalls, and does so with the shost->scan_mutex held.
If, at this point, if any scan or delete request is made on the host, it
will stall waiting for the scan_mutex.
For the FC transport, we queue all delete work to a single workq.
So, things worked fine when competing with the scan, as long as the
target blocking the scan was the same target at the top of our delete
workq, as the delete workq routine always unblocked just prior to
requesting the delete. Unfortunately, if the top of our delete workq
was for a different target, we deadlock. Additionally, if the target
blocking scan returned, we were unblocking it in the scan workq routine,
which really won't execute until the existing stalled scan workq
completes (e.g. we're re-scheduling it while it is in the midst of its
execution).
This patch moves the unblock out of the workq routines and moves it to
the context that is scheduling the work. This ensures that at some point,
we will unblock the target that is blocking scan. Please note, however,
that the deadlock condition may still occur while it waits for the
transport to timeout an unblock on a target. Worst case, this is bounded
by the transport dev_loss_tmo (default: 30 seconds).
Finally, Michael Reed deserves the credit for the bulk of this patch,
analysis, and it's testing. Thank you for your help.
Note: The request for comments statements about the gross-ness of the
scan_mutex still stand.
Signed-off-by: Michael Reed <mdr@sgi.com>
Signed-off-by: James Smart <james.smart@emulex.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-05-11 11:27:09 -06:00
|
|
|
* 1 - work queued for execution
|
|
|
|
* 0 - work is already queued
|
|
|
|
* -EINVAL - work queue doesn't exist
|
2007-11-03 12:30:39 -06:00
|
|
|
*/
|
2006-04-10 08:14:05 -06:00
|
|
|
static int
|
|
|
|
fc_queue_work(struct Scsi_Host *shost, struct work_struct *work)
|
|
|
|
{
|
|
|
|
if (unlikely(!fc_host_work_q(shost))) {
|
|
|
|
printk(KERN_ERR
|
|
|
|
"ERROR: FC host '%s' attempted to queue work, "
|
|
|
|
"when no workqueue created.\n", shost->hostt->name);
|
|
|
|
dump_stack();
|
|
|
|
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return queue_work(fc_host_work_q(shost), work);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fc_flush_work - Flush a fc_host's workqueue.
|
|
|
|
* @shost: Pointer to Scsi_Host bound to fc_host.
|
2007-11-03 12:30:39 -06:00
|
|
|
*/
|
2006-04-10 08:14:05 -06:00
|
|
|
static void
|
|
|
|
fc_flush_work(struct Scsi_Host *shost)
|
|
|
|
{
|
|
|
|
if (!fc_host_work_q(shost)) {
|
|
|
|
printk(KERN_ERR
|
|
|
|
"ERROR: FC host '%s' attempted to flush work, "
|
|
|
|
"when no workqueue created.\n", shost->hostt->name);
|
|
|
|
dump_stack();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
flush_workqueue(fc_host_work_q(shost));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fc_queue_devloss_work - Schedule work for the fc_host devloss workqueue.
|
|
|
|
* @shost: Pointer to Scsi_Host bound to fc_host.
|
|
|
|
* @work: Work to queue for execution.
|
|
|
|
* @delay: jiffies to delay the work queuing
|
|
|
|
*
|
|
|
|
* Return value:
|
2006-08-18 15:33:29 -06:00
|
|
|
* 1 on success / 0 already queued / < 0 for error
|
2007-11-03 12:30:39 -06:00
|
|
|
*/
|
2006-04-10 08:14:05 -06:00
|
|
|
static int
|
2006-11-22 07:57:56 -07:00
|
|
|
fc_queue_devloss_work(struct Scsi_Host *shost, struct delayed_work *work,
|
2006-04-10 08:14:05 -06:00
|
|
|
unsigned long delay)
|
|
|
|
{
|
|
|
|
if (unlikely(!fc_host_devloss_work_q(shost))) {
|
|
|
|
printk(KERN_ERR
|
|
|
|
"ERROR: FC host '%s' attempted to queue work, "
|
|
|
|
"when no workqueue created.\n", shost->hostt->name);
|
|
|
|
dump_stack();
|
|
|
|
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return queue_delayed_work(fc_host_devloss_work_q(shost), work, delay);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fc_flush_devloss - Flush a fc_host's devloss workqueue.
|
|
|
|
* @shost: Pointer to Scsi_Host bound to fc_host.
|
2007-11-03 12:30:39 -06:00
|
|
|
*/
|
2006-04-10 08:14:05 -06:00
|
|
|
static void
|
|
|
|
fc_flush_devloss(struct Scsi_Host *shost)
|
|
|
|
{
|
|
|
|
if (!fc_host_devloss_work_q(shost)) {
|
|
|
|
printk(KERN_ERR
|
|
|
|
"ERROR: FC host '%s' attempted to flush work, "
|
|
|
|
"when no workqueue created.\n", shost->hostt->name);
|
|
|
|
dump_stack();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
flush_workqueue(fc_host_devloss_work_q(shost));
|
|
|
|
}
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/**
|
2007-11-03 12:30:39 -06:00
|
|
|
* fc_remove_host - called to terminate any fc_transport-related elements for a scsi host.
|
|
|
|
* @shost: Which &Scsi_Host
|
2005-04-16 16:20:36 -06:00
|
|
|
*
|
2011-03-30 19:57:33 -06:00
|
|
|
* This routine is expected to be called immediately preceding the
|
2005-04-16 16:20:36 -06:00
|
|
|
* a driver's call to scsi_remove_host().
|
|
|
|
*
|
|
|
|
* WARNING: A driver utilizing the fc_transport, which fails to call
|
2007-11-03 12:30:39 -06:00
|
|
|
* this routine prior to scsi_remove_host(), will leave dangling
|
2005-04-16 16:20:36 -06:00
|
|
|
* objects in /sys/class/fc_remote_ports. Access to any of these
|
|
|
|
* objects can result in a system crash !!!
|
|
|
|
*
|
|
|
|
* Notes:
|
|
|
|
* This routine assumes no locks are held on entry.
|
2007-11-03 12:30:39 -06:00
|
|
|
*/
|
2005-04-16 16:20:36 -06:00
|
|
|
void
|
|
|
|
fc_remove_host(struct Scsi_Host *shost)
|
|
|
|
{
|
2007-04-27 10:41:09 -06:00
|
|
|
struct fc_vport *vport = NULL, *next_vport = NULL;
|
|
|
|
struct fc_rport *rport = NULL, *next_rport = NULL;
|
2006-04-10 08:14:05 -06:00
|
|
|
struct workqueue_struct *work_q;
|
|
|
|
struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
|
2007-04-27 10:41:09 -06:00
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(shost->host_lock, flags);
|
|
|
|
|
|
|
|
/* Remove any vports */
|
2017-07-24 04:09:36 -06:00
|
|
|
list_for_each_entry_safe(vport, next_vport, &fc_host->vports, peers) {
|
|
|
|
vport->flags |= FC_VPORT_DELETING;
|
2007-05-24 17:04:44 -06:00
|
|
|
fc_queue_work(shost, &vport->vport_delete_work);
|
2017-07-24 04:09:36 -06:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Remove any remote ports */
|
|
|
|
list_for_each_entry_safe(rport, next_rport,
|
2006-04-10 08:14:05 -06:00
|
|
|
&fc_host->rports, peers) {
|
|
|
|
list_del(&rport->peers);
|
|
|
|
rport->port_state = FC_PORTSTATE_DELETED;
|
|
|
|
fc_queue_work(shost, &rport->rport_delete_work);
|
|
|
|
}
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
list_for_each_entry_safe(rport, next_rport,
|
2006-04-10 08:14:05 -06:00
|
|
|
&fc_host->rport_bindings, peers) {
|
|
|
|
list_del(&rport->peers);
|
|
|
|
rport->port_state = FC_PORTSTATE_DELETED;
|
|
|
|
fc_queue_work(shost, &rport->rport_delete_work);
|
|
|
|
}
|
|
|
|
|
2007-04-27 10:41:09 -06:00
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
|
|
|
|
2006-04-10 08:14:05 -06:00
|
|
|
/* flush all scan work items */
|
|
|
|
scsi_flush_work(shost);
|
|
|
|
|
|
|
|
/* flush all stgt delete, and rport delete work items, then kill it */
|
|
|
|
if (fc_host->work_q) {
|
|
|
|
work_q = fc_host->work_q;
|
|
|
|
fc_host->work_q = NULL;
|
|
|
|
destroy_workqueue(work_q);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* flush all devloss work items, then kill it */
|
|
|
|
if (fc_host->devloss_work_q) {
|
|
|
|
work_q = fc_host->devloss_work_q;
|
|
|
|
fc_host->devloss_work_q = NULL;
|
|
|
|
destroy_workqueue(work_q);
|
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(fc_remove_host);
|
|
|
|
|
2008-08-19 17:45:23 -06:00
|
|
|
static void fc_terminate_rport_io(struct fc_rport *rport)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = rport_to_shost(rport);
|
|
|
|
struct fc_internal *i = to_fc_internal(shost->transportt);
|
|
|
|
|
|
|
|
/* Involve the LLDD if possible to terminate all io on the rport. */
|
|
|
|
if (i->f->terminate_rport_io)
|
|
|
|
i->f->terminate_rport_io(rport);
|
|
|
|
|
|
|
|
/*
|
2012-05-17 22:56:57 -06:00
|
|
|
* Must unblock to flush queued IO. scsi-ml will fail incoming reqs.
|
2008-08-19 17:45:23 -06:00
|
|
|
*/
|
2012-05-17 22:56:57 -06:00
|
|
|
scsi_target_unblock(&rport->dev, SDEV_TRANSPORT_OFFLINE);
|
2008-08-19 17:45:23 -06:00
|
|
|
}
|
2006-04-10 08:14:05 -06:00
|
|
|
|
|
|
|
/**
|
2011-03-30 19:57:33 -06:00
|
|
|
* fc_starget_delete - called to delete the scsi descendants of an rport
|
2006-11-22 07:57:56 -07:00
|
|
|
* @work: remote port to be operated on.
|
2007-11-03 12:30:39 -06:00
|
|
|
*
|
|
|
|
* Deletes target and all sdevs.
|
|
|
|
*/
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
static void
|
2006-11-22 07:57:56 -07:00
|
|
|
fc_starget_delete(struct work_struct *work)
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
{
|
2006-11-22 07:57:56 -07:00
|
|
|
struct fc_rport *rport =
|
|
|
|
container_of(work, struct fc_rport, stgt_delete_work);
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
|
2008-08-19 17:45:23 -06:00
|
|
|
fc_terminate_rport_io(rport);
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
scsi_remove_target(&rport->dev);
|
|
|
|
}
|
|
|
|
|
2006-04-10 08:14:05 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* fc_rport_final_delete - finish rport termination and delete it.
|
2006-11-22 07:57:56 -07:00
|
|
|
* @work: remote port to be deleted.
|
2007-11-03 12:30:39 -06:00
|
|
|
*/
|
2006-04-10 08:14:05 -06:00
|
|
|
static void
|
2006-11-22 07:57:56 -07:00
|
|
|
fc_rport_final_delete(struct work_struct *work)
|
2006-04-10 08:14:05 -06:00
|
|
|
{
|
2006-11-22 07:57:56 -07:00
|
|
|
struct fc_rport *rport =
|
|
|
|
container_of(work, struct fc_rport, rport_delete_work);
|
2006-04-10 08:14:05 -06:00
|
|
|
struct device *dev = &rport->dev;
|
|
|
|
struct Scsi_Host *shost = rport_to_shost(rport);
|
2006-08-18 15:33:29 -06:00
|
|
|
struct fc_internal *i = to_fc_internal(shost->transportt);
|
2007-04-27 09:53:17 -06:00
|
|
|
unsigned long flags;
|
2009-10-09 13:15:59 -06:00
|
|
|
int do_callback = 0;
|
2006-04-10 08:14:05 -06:00
|
|
|
|
2011-04-25 13:30:06 -06:00
|
|
|
fc_terminate_rport_io(rport);
|
|
|
|
|
2006-04-10 08:14:05 -06:00
|
|
|
/*
|
2007-05-24 17:04:44 -06:00
|
|
|
* if a scan is pending, flush the SCSI Host work_q so that
|
2006-04-10 08:14:05 -06:00
|
|
|
* that we can reclaim the rport scan work element.
|
|
|
|
*/
|
|
|
|
if (rport->flags & FC_RPORT_SCAN_PENDING)
|
|
|
|
scsi_flush_work(shost);
|
|
|
|
|
2007-04-27 09:53:17 -06:00
|
|
|
/*
|
|
|
|
* Cancel any outstanding timers. These should really exist
|
|
|
|
* only when rmmod'ing the LLDD and we're asking for
|
|
|
|
* immediate termination of the rports
|
|
|
|
*/
|
|
|
|
spin_lock_irqsave(shost->host_lock, flags);
|
|
|
|
if (rport->flags & FC_RPORT_DEVLOSS_PENDING) {
|
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
|
|
|
if (!cancel_delayed_work(&rport->fail_io_work))
|
|
|
|
fc_flush_devloss(shost);
|
|
|
|
if (!cancel_delayed_work(&rport->dev_loss_work))
|
|
|
|
fc_flush_devloss(shost);
|
2014-06-23 08:40:25 -06:00
|
|
|
cancel_work_sync(&rport->scan_work);
|
2007-04-27 09:53:17 -06:00
|
|
|
spin_lock_irqsave(shost->host_lock, flags);
|
|
|
|
rport->flags &= ~FC_RPORT_DEVLOSS_PENDING;
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
|
|
|
|
2006-08-18 15:33:29 -06:00
|
|
|
/* Delete SCSI target and sdevs */
|
|
|
|
if (rport->scsi_target_id != -1)
|
2006-11-22 07:57:56 -07:00
|
|
|
fc_starget_delete(&rport->stgt_delete_work);
|
2007-04-27 09:53:17 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Notify the driver that the rport is now dead. The LLDD will
|
|
|
|
* also guarantee that any communication to the rport is terminated
|
2009-01-05 10:14:18 -07:00
|
|
|
*
|
|
|
|
* Avoid this call if we already called it when we preserved the
|
|
|
|
* rport for the binding.
|
2007-04-27 09:53:17 -06:00
|
|
|
*/
|
2009-10-09 13:15:59 -06:00
|
|
|
spin_lock_irqsave(shost->host_lock, flags);
|
2009-01-05 10:14:18 -07:00
|
|
|
if (!(rport->flags & FC_RPORT_DEVLOSS_CALLBK_DONE) &&
|
2009-10-09 13:15:59 -06:00
|
|
|
(i->f->dev_loss_tmo_callbk)) {
|
|
|
|
rport->flags |= FC_RPORT_DEVLOSS_CALLBK_DONE;
|
|
|
|
do_callback = 1;
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
|
|
|
|
|
|
|
if (do_callback)
|
2006-08-18 15:33:29 -06:00
|
|
|
i->f->dev_loss_tmo_callbk(rport);
|
|
|
|
|
2009-03-26 11:33:19 -06:00
|
|
|
fc_bsg_remove(rport->rqst_q);
|
|
|
|
|
2006-04-10 08:14:05 -06:00
|
|
|
transport_remove_device(dev);
|
|
|
|
device_del(dev);
|
|
|
|
transport_destroy_device(dev);
|
2015-11-20 14:33:04 -07:00
|
|
|
scsi_host_put(shost); /* for fc_host->rport list */
|
2006-06-26 12:19:59 -06:00
|
|
|
put_device(dev); /* for self-reference */
|
2006-04-10 08:14:05 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/**
|
2016-10-18 02:01:41 -06:00
|
|
|
* fc_remote_port_create - allocates and creates a remote FC port.
|
2005-04-16 16:20:36 -06:00
|
|
|
* @shost: scsi host the remote port is connected to.
|
|
|
|
* @channel: Channel on shost port connected to.
|
|
|
|
* @ids: The world wide names, fc address, and FC4 port
|
|
|
|
* roles for the remote port.
|
|
|
|
*
|
|
|
|
* Allocates and creates the remoter port structure, including the
|
|
|
|
* class and sysfs creation.
|
|
|
|
*
|
|
|
|
* Notes:
|
|
|
|
* This routine assumes no locks are held on entry.
|
2007-11-03 12:30:39 -06:00
|
|
|
*/
|
2007-07-09 12:59:59 -06:00
|
|
|
static struct fc_rport *
|
2016-10-18 02:01:41 -06:00
|
|
|
fc_remote_port_create(struct Scsi_Host *shost, int channel,
|
|
|
|
struct fc_rport_identifiers *ids)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2006-04-10 08:14:05 -06:00
|
|
|
struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
|
2005-04-16 16:20:36 -06:00
|
|
|
struct fc_internal *fci = to_fc_internal(shost->transportt);
|
|
|
|
struct fc_rport *rport;
|
|
|
|
struct device *dev;
|
|
|
|
unsigned long flags;
|
|
|
|
int error;
|
|
|
|
size_t size;
|
|
|
|
|
|
|
|
size = (sizeof(struct fc_rport) + fci->f->dd_fcrport_size);
|
2006-01-16 08:31:18 -07:00
|
|
|
rport = kzalloc(size, GFP_KERNEL);
|
2005-04-16 16:20:36 -06:00
|
|
|
if (unlikely(!rport)) {
|
2008-07-04 00:47:27 -06:00
|
|
|
printk(KERN_ERR "%s: allocation failure\n", __func__);
|
2005-04-16 16:20:36 -06:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
rport->maxframe_size = -1;
|
|
|
|
rport->supported_classes = FC_COS_UNSPECIFIED;
|
2010-09-15 15:52:32 -06:00
|
|
|
rport->dev_loss_tmo = fc_host->dev_loss_tmo;
|
2005-04-16 16:20:36 -06:00
|
|
|
memcpy(&rport->node_name, &ids->node_name, sizeof(rport->node_name));
|
|
|
|
memcpy(&rport->port_name, &ids->port_name, sizeof(rport->port_name));
|
|
|
|
rport->port_id = ids->port_id;
|
|
|
|
rport->roles = ids->roles;
|
|
|
|
rport->port_state = FC_PORTSTATE_ONLINE;
|
|
|
|
if (fci->f->dd_fcrport_size)
|
|
|
|
rport->dd_data = &rport[1];
|
|
|
|
rport->channel = channel;
|
2006-08-18 15:33:29 -06:00
|
|
|
rport->fast_io_fail_tmo = -1;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2006-11-22 07:57:56 -07:00
|
|
|
INIT_DELAYED_WORK(&rport->dev_loss_work, fc_timeout_deleted_rport);
|
|
|
|
INIT_DELAYED_WORK(&rport->fail_io_work, fc_timeout_fail_rport_io);
|
|
|
|
INIT_WORK(&rport->scan_work, fc_scsi_scan_rport);
|
|
|
|
INIT_WORK(&rport->stgt_delete_work, fc_starget_delete);
|
|
|
|
INIT_WORK(&rport->rport_delete_work, fc_rport_final_delete);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
spin_lock_irqsave(shost->host_lock, flags);
|
|
|
|
|
|
|
|
rport->number = fc_host->next_rport_number++;
|
2017-04-17 12:37:45 -06:00
|
|
|
if ((rport->roles & FC_PORT_ROLE_FCP_TARGET) ||
|
|
|
|
(rport->roles & FC_PORT_ROLE_FCP_DUMMY_INITIATOR))
|
2005-04-16 16:20:36 -06:00
|
|
|
rport->scsi_target_id = fc_host->next_target_id++;
|
|
|
|
else
|
|
|
|
rport->scsi_target_id = -1;
|
2006-04-10 08:14:05 -06:00
|
|
|
list_add_tail(&rport->peers, &fc_host->rports);
|
2015-11-20 14:33:04 -07:00
|
|
|
scsi_host_get(shost); /* for fc_host->rport list */
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
|
|
|
|
|
|
|
dev = &rport->dev;
|
2006-06-26 12:19:59 -06:00
|
|
|
device_initialize(dev); /* takes self reference */
|
|
|
|
dev->parent = get_device(&shost->shost_gendev); /* parent reference */
|
2005-04-16 16:20:36 -06:00
|
|
|
dev->release = fc_rport_dev_release;
|
2008-12-03 14:41:36 -07:00
|
|
|
dev_set_name(dev, "rport-%d:%d-%d",
|
|
|
|
shost->host_no, channel, rport->number);
|
2005-04-16 16:20:36 -06:00
|
|
|
transport_setup_device(dev);
|
|
|
|
|
|
|
|
error = device_add(dev);
|
|
|
|
if (error) {
|
|
|
|
printk(KERN_ERR "FC Remote Port device_add failed\n");
|
|
|
|
goto delete_rport;
|
|
|
|
}
|
|
|
|
transport_add_device(dev);
|
|
|
|
transport_configure_device(dev);
|
|
|
|
|
2009-03-26 11:33:19 -06:00
|
|
|
fc_bsg_rportadd(shost, rport);
|
|
|
|
/* ignore any bsg add error - we just can't do sgio */
|
|
|
|
|
2007-04-27 10:41:09 -06:00
|
|
|
if (rport->roles & FC_PORT_ROLE_FCP_TARGET) {
|
2005-04-16 16:20:36 -06:00
|
|
|
/* initiate a scan of the target */
|
2006-04-10 08:14:05 -06:00
|
|
|
rport->flags |= FC_RPORT_SCAN_PENDING;
|
2005-04-16 16:20:36 -06:00
|
|
|
scsi_queue_work(shost, &rport->scan_work);
|
2006-04-10 08:14:05 -06:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
return rport;
|
|
|
|
|
|
|
|
delete_rport:
|
|
|
|
transport_destroy_device(dev);
|
|
|
|
spin_lock_irqsave(shost->host_lock, flags);
|
|
|
|
list_del(&rport->peers);
|
2015-11-20 14:33:04 -07:00
|
|
|
scsi_host_put(shost); /* for fc_host->rport list */
|
2005-04-16 16:20:36 -06:00
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
|
|
|
put_device(dev->parent);
|
|
|
|
kfree(rport);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2007-11-03 12:30:39 -06:00
|
|
|
* fc_remote_port_add - notify fc transport of the existence of a remote FC port.
|
2005-04-16 16:20:36 -06:00
|
|
|
* @shost: scsi host the remote port is connected to.
|
|
|
|
* @channel: Channel on shost port connected to.
|
|
|
|
* @ids: The world wide names, fc address, and FC4 port
|
|
|
|
* roles for the remote port.
|
|
|
|
*
|
|
|
|
* The LLDD calls this routine to notify the transport of the existence
|
|
|
|
* of a remote port. The LLDD provides the unique identifiers (wwpn,wwn)
|
|
|
|
* of the port, it's FC address (port_id), and the FC4 roles that are
|
|
|
|
* active for the port.
|
|
|
|
*
|
|
|
|
* For ports that are FCP targets (aka scsi targets), the FC transport
|
|
|
|
* maintains consistent target id bindings on behalf of the LLDD.
|
|
|
|
* A consistent target id binding is an assignment of a target id to
|
|
|
|
* a remote port identifier, which persists while the scsi host is
|
|
|
|
* attached. The remote port can disappear, then later reappear, and
|
|
|
|
* it's target id assignment remains the same. This allows for shifts
|
|
|
|
* in FC addressing (if binding by wwpn or wwnn) with no apparent
|
|
|
|
* changes to the scsi subsystem which is based on scsi host number and
|
|
|
|
* target id values. Bindings are only valid during the attachment of
|
|
|
|
* the scsi host. If the host detaches, then later re-attaches, target
|
|
|
|
* id bindings may change.
|
|
|
|
*
|
|
|
|
* This routine is responsible for returning a remote port structure.
|
|
|
|
* The routine will search the list of remote ports it maintains
|
|
|
|
* internally on behalf of consistent target id mappings. If found, the
|
|
|
|
* remote port structure will be reused. Otherwise, a new remote port
|
|
|
|
* structure will be allocated.
|
|
|
|
*
|
|
|
|
* Whenever a remote port is allocated, a new fc_remote_port class
|
|
|
|
* device is created.
|
|
|
|
*
|
|
|
|
* Should not be called from interrupt context.
|
|
|
|
*
|
|
|
|
* Notes:
|
|
|
|
* This routine assumes no locks are held on entry.
|
2007-11-03 12:30:39 -06:00
|
|
|
*/
|
2005-04-16 16:20:36 -06:00
|
|
|
struct fc_rport *
|
|
|
|
fc_remote_port_add(struct Scsi_Host *shost, int channel,
|
|
|
|
struct fc_rport_identifiers *ids)
|
|
|
|
{
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
struct fc_internal *fci = to_fc_internal(shost->transportt);
|
2006-04-10 08:14:05 -06:00
|
|
|
struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
|
2005-04-16 16:20:36 -06:00
|
|
|
struct fc_rport *rport;
|
|
|
|
unsigned long flags;
|
|
|
|
int match = 0;
|
|
|
|
|
2006-04-10 08:14:05 -06:00
|
|
|
/* ensure any stgt delete functions are done */
|
|
|
|
fc_flush_work(shost);
|
|
|
|
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
/*
|
|
|
|
* Search the list of "active" rports, for an rport that has been
|
|
|
|
* deleted, but we've held off the real delete while the target
|
|
|
|
* is in a "blocked" state.
|
|
|
|
*/
|
|
|
|
spin_lock_irqsave(shost->host_lock, flags);
|
|
|
|
|
2006-04-10 08:14:05 -06:00
|
|
|
list_for_each_entry(rport, &fc_host->rports, peers) {
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
|
|
|
|
if ((rport->port_state == FC_PORTSTATE_BLOCKED) &&
|
|
|
|
(rport->channel == channel)) {
|
|
|
|
|
2006-04-10 08:14:05 -06:00
|
|
|
switch (fc_host->tgtid_bind_type) {
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
case FC_TGTID_BIND_BY_WWPN:
|
|
|
|
case FC_TGTID_BIND_NONE:
|
|
|
|
if (rport->port_name == ids->port_name)
|
|
|
|
match = 1;
|
|
|
|
break;
|
|
|
|
case FC_TGTID_BIND_BY_WWNN:
|
|
|
|
if (rport->node_name == ids->node_name)
|
|
|
|
match = 1;
|
|
|
|
break;
|
|
|
|
case FC_TGTID_BIND_BY_ID:
|
|
|
|
if (rport->port_id == ids->port_id)
|
|
|
|
match = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (match) {
|
|
|
|
|
|
|
|
memcpy(&rport->node_name, &ids->node_name,
|
|
|
|
sizeof(rport->node_name));
|
|
|
|
memcpy(&rport->port_name, &ids->port_name,
|
|
|
|
sizeof(rport->port_name));
|
|
|
|
rport->port_id = ids->port_id;
|
|
|
|
|
|
|
|
rport->port_state = FC_PORTSTATE_ONLINE;
|
|
|
|
rport->roles = ids->roles;
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
|
|
|
|
|
|
|
if (fci->f->dd_fcrport_size)
|
|
|
|
memset(rport->dd_data, 0,
|
|
|
|
fci->f->dd_fcrport_size);
|
|
|
|
|
|
|
|
/*
|
2007-04-27 09:53:17 -06:00
|
|
|
* If we were not a target, cancel the
|
|
|
|
* io terminate and rport timers, and
|
|
|
|
* we're done.
|
|
|
|
*
|
|
|
|
* If we were a target, but our new role
|
|
|
|
* doesn't indicate a target, leave the
|
|
|
|
* timers running expecting the role to
|
|
|
|
* change as the target fully logs in. If
|
|
|
|
* it doesn't, the target will be torn down.
|
|
|
|
*
|
|
|
|
* If we were a target, and our role shows
|
|
|
|
* we're still a target, cancel the timers
|
|
|
|
* and kick off a scan.
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
*/
|
|
|
|
|
2007-04-27 09:53:17 -06:00
|
|
|
/* was a target, not in roles */
|
|
|
|
if ((rport->scsi_target_id != -1) &&
|
2007-04-27 10:41:09 -06:00
|
|
|
(!(ids->roles & FC_PORT_ROLE_FCP_TARGET)))
|
2007-04-27 09:53:17 -06:00
|
|
|
return rport;
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
|
|
|
|
/*
|
2007-04-27 09:53:17 -06:00
|
|
|
* Stop the fail io and dev_loss timers.
|
|
|
|
* If they flush, the port_state will
|
|
|
|
* be checked and will NOOP the function.
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
*/
|
2006-08-18 15:33:29 -06:00
|
|
|
if (!cancel_delayed_work(&rport->fail_io_work))
|
|
|
|
fc_flush_devloss(shost);
|
2007-04-27 09:53:17 -06:00
|
|
|
if (!cancel_delayed_work(&rport->dev_loss_work))
|
2006-04-10 08:14:05 -06:00
|
|
|
fc_flush_devloss(shost);
|
|
|
|
|
|
|
|
spin_lock_irqsave(shost->host_lock, flags);
|
|
|
|
|
2008-08-19 17:45:23 -06:00
|
|
|
rport->flags &= ~(FC_RPORT_FAST_FAIL_TIMEDOUT |
|
2009-01-05 10:14:18 -07:00
|
|
|
FC_RPORT_DEVLOSS_PENDING |
|
|
|
|
FC_RPORT_DEVLOSS_CALLBK_DONE);
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
|
2012-04-15 20:47:50 -06:00
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
|
|
|
|
2007-04-27 09:53:17 -06:00
|
|
|
/* if target, initiate a scan */
|
|
|
|
if (rport->scsi_target_id != -1) {
|
2012-05-17 22:56:57 -06:00
|
|
|
scsi_target_unblock(&rport->dev,
|
|
|
|
SDEV_RUNNING);
|
2012-04-15 20:47:50 -06:00
|
|
|
spin_lock_irqsave(shost->host_lock,
|
|
|
|
flags);
|
2007-04-27 09:53:17 -06:00
|
|
|
rport->flags |= FC_RPORT_SCAN_PENDING;
|
|
|
|
scsi_queue_work(shost,
|
|
|
|
&rport->scan_work);
|
|
|
|
spin_unlock_irqrestore(shost->host_lock,
|
|
|
|
flags);
|
2012-04-15 20:47:50 -06:00
|
|
|
}
|
[SCSI] fc transport: resolve scan vs delete deadlocks
In a prior posting to linux-scsi on the fc transport and workq
deadlocks, we noted a second error that did not have a patch:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114467847711383&w=2
- There's a deadlock where scsi_remove_target() has to sit behind
scsi_scan_target() due to contention over the scan_lock().
Subsequently we posted a request for comments about the deadlock:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114469358829500&w=2
This posting resolves the second error. Here's what we now understand,
and are implementing:
If the lldd deletes the rport while a scan is active, the sdev's queue
is blocked which stops the issuing of commands associated with the scan.
At this point, the scan stalls, and does so with the shost->scan_mutex held.
If, at this point, if any scan or delete request is made on the host, it
will stall waiting for the scan_mutex.
For the FC transport, we queue all delete work to a single workq.
So, things worked fine when competing with the scan, as long as the
target blocking the scan was the same target at the top of our delete
workq, as the delete workq routine always unblocked just prior to
requesting the delete. Unfortunately, if the top of our delete workq
was for a different target, we deadlock. Additionally, if the target
blocking scan returned, we were unblocking it in the scan workq routine,
which really won't execute until the existing stalled scan workq
completes (e.g. we're re-scheduling it while it is in the midst of its
execution).
This patch moves the unblock out of the workq routines and moves it to
the context that is scheduling the work. This ensures that at some point,
we will unblock the target that is blocking scan. Please note, however,
that the deadlock condition may still occur while it waits for the
transport to timeout an unblock on a target. Worst case, this is bounded
by the transport dev_loss_tmo (default: 30 seconds).
Finally, Michael Reed deserves the credit for the bulk of this patch,
analysis, and it's testing. Thank you for your help.
Note: The request for comments statements about the gross-ness of the
scan_mutex still stand.
Signed-off-by: Michael Reed <mdr@sgi.com>
Signed-off-by: James Smart <james.smart@emulex.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-05-11 11:27:09 -06:00
|
|
|
|
2009-03-26 11:33:19 -06:00
|
|
|
fc_bsg_goose_queue(rport);
|
|
|
|
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
return rport;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-27 09:53:17 -06:00
|
|
|
/*
|
|
|
|
* Search the bindings array
|
|
|
|
* Note: if never a FCP target, you won't be on this list
|
|
|
|
*/
|
2006-04-10 08:14:05 -06:00
|
|
|
if (fc_host->tgtid_bind_type != FC_TGTID_BIND_NONE) {
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* search for a matching consistent binding */
|
|
|
|
|
2006-04-10 08:14:05 -06:00
|
|
|
list_for_each_entry(rport, &fc_host->rport_bindings,
|
2005-04-16 16:20:36 -06:00
|
|
|
peers) {
|
|
|
|
if (rport->channel != channel)
|
|
|
|
continue;
|
|
|
|
|
2006-04-10 08:14:05 -06:00
|
|
|
switch (fc_host->tgtid_bind_type) {
|
2005-04-16 16:20:36 -06:00
|
|
|
case FC_TGTID_BIND_BY_WWPN:
|
|
|
|
if (rport->port_name == ids->port_name)
|
|
|
|
match = 1;
|
|
|
|
break;
|
|
|
|
case FC_TGTID_BIND_BY_WWNN:
|
|
|
|
if (rport->node_name == ids->node_name)
|
|
|
|
match = 1;
|
|
|
|
break;
|
|
|
|
case FC_TGTID_BIND_BY_ID:
|
|
|
|
if (rport->port_id == ids->port_id)
|
|
|
|
match = 1;
|
|
|
|
break;
|
|
|
|
case FC_TGTID_BIND_NONE: /* to keep compiler happy */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (match) {
|
2006-04-10 08:14:05 -06:00
|
|
|
list_move_tail(&rport->peers, &fc_host->rports);
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (match) {
|
|
|
|
memcpy(&rport->node_name, &ids->node_name,
|
|
|
|
sizeof(rport->node_name));
|
|
|
|
memcpy(&rport->port_name, &ids->port_name,
|
|
|
|
sizeof(rport->port_name));
|
|
|
|
rport->port_id = ids->port_id;
|
|
|
|
rport->roles = ids->roles;
|
|
|
|
rport->port_state = FC_PORTSTATE_ONLINE;
|
2008-08-19 17:45:23 -06:00
|
|
|
rport->flags &= ~FC_RPORT_FAST_FAIL_TIMEDOUT;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
if (fci->f->dd_fcrport_size)
|
|
|
|
memset(rport->dd_data, 0,
|
|
|
|
fci->f->dd_fcrport_size);
|
2012-04-15 20:47:50 -06:00
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
|
|
|
|
|
|
|
if (ids->roles & FC_PORT_ROLE_FCP_TARGET) {
|
2012-05-17 22:56:57 -06:00
|
|
|
scsi_target_unblock(&rport->dev, SDEV_RUNNING);
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/* initiate a scan of the target */
|
2012-04-15 20:47:50 -06:00
|
|
|
spin_lock_irqsave(shost->host_lock, flags);
|
2006-04-10 08:14:05 -06:00
|
|
|
rport->flags |= FC_RPORT_SCAN_PENDING;
|
2005-04-16 16:20:36 -06:00
|
|
|
scsi_queue_work(shost, &rport->scan_work);
|
[SCSI] fc transport: resolve scan vs delete deadlocks
In a prior posting to linux-scsi on the fc transport and workq
deadlocks, we noted a second error that did not have a patch:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114467847711383&w=2
- There's a deadlock where scsi_remove_target() has to sit behind
scsi_scan_target() due to contention over the scan_lock().
Subsequently we posted a request for comments about the deadlock:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114469358829500&w=2
This posting resolves the second error. Here's what we now understand,
and are implementing:
If the lldd deletes the rport while a scan is active, the sdev's queue
is blocked which stops the issuing of commands associated with the scan.
At this point, the scan stalls, and does so with the shost->scan_mutex held.
If, at this point, if any scan or delete request is made on the host, it
will stall waiting for the scan_mutex.
For the FC transport, we queue all delete work to a single workq.
So, things worked fine when competing with the scan, as long as the
target blocking the scan was the same target at the top of our delete
workq, as the delete workq routine always unblocked just prior to
requesting the delete. Unfortunately, if the top of our delete workq
was for a different target, we deadlock. Additionally, if the target
blocking scan returned, we were unblocking it in the scan workq routine,
which really won't execute until the existing stalled scan workq
completes (e.g. we're re-scheduling it while it is in the midst of its
execution).
This patch moves the unblock out of the workq routines and moves it to
the context that is scheduling the work. This ensures that at some point,
we will unblock the target that is blocking scan. Please note, however,
that the deadlock condition may still occur while it waits for the
transport to timeout an unblock on a target. Worst case, this is bounded
by the transport dev_loss_tmo (default: 30 seconds).
Finally, Michael Reed deserves the credit for the bulk of this patch,
analysis, and it's testing. Thank you for your help.
Note: The request for comments statements about the gross-ness of the
scan_mutex still stand.
Signed-off-by: Michael Reed <mdr@sgi.com>
Signed-off-by: James Smart <james.smart@emulex.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-05-11 11:27:09 -06:00
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
2012-04-15 20:47:50 -06:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
return rport;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/* No consistent binding found - create new remote port entry */
|
2016-10-18 02:01:41 -06:00
|
|
|
rport = fc_remote_port_create(shost, channel, ids);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
return rport;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(fc_remote_port_add);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2007-11-03 12:30:39 -06:00
|
|
|
* fc_remote_port_delete - notifies the fc transport that a remote port is no longer in existence.
|
2005-04-16 16:20:36 -06:00
|
|
|
* @rport: The remote port that no longer exists
|
|
|
|
*
|
|
|
|
* The LLDD calls this routine to notify the transport that a remote
|
|
|
|
* port is no longer part of the topology. Note: Although a port
|
|
|
|
* may no longer be part of the topology, it may persist in the remote
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
* ports displayed by the fc_host. We do this under 2 conditions:
|
2017-05-12 07:04:14 -06:00
|
|
|
*
|
2007-11-03 12:30:39 -06:00
|
|
|
* 1) If the port was a scsi target, we delay its deletion by "blocking" it.
|
2017-05-12 07:04:14 -06:00
|
|
|
* This allows the port to temporarily disappear, then reappear without
|
|
|
|
* disrupting the SCSI device tree attached to it. During the "blocked"
|
|
|
|
* period the port will still exist.
|
|
|
|
*
|
2007-11-03 12:30:39 -06:00
|
|
|
* 2) If the port was a scsi target and disappears for longer than we
|
2017-05-12 07:04:14 -06:00
|
|
|
* expect, we'll delete the port and the tear down the SCSI device tree
|
|
|
|
* attached to it. However, we want to semi-persist the target id assigned
|
|
|
|
* to that port if it eventually does exist. The port structure will
|
|
|
|
* remain (although with minimal information) so that the target id
|
SCSI misc on 20170704
This is mostly updates of the usual suspects: lpfc, qla2xxx, bnx2fc,
qedf, hpsa, hisi_sas, smartpqi, cxlflash, aacraid, csiostor along with
a host of minor and miscellaneous changes.
Signed-off-by: James E.J. Bottomley <jejb@linux.vnet.ibm.com>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQIcBAABAgAGBQJZW7JMAAoJEAVr7HOZEZN4IM4P/AqBtvH+6Lo1Eb+3A/HnHskK
hIxVxgBxaw3fhW5AegDfVCvrdVTTEkCB/g5CIKN8NCWEx6OGmCX0Lu6lnjld9BOZ
cTlPtzNwFGlgHrz34LwCc3vlc5ovMpTQBrpGAQpGGWoAZIP+c3ilEihIYTEMNCsN
dmjI71AigDE5g6X1OT361IJ1gydkjfG41IcRe/jlMtEgRNdy3B2JVIdATL89Pw4b
0uZO3uUTn8EGEKUdyJZCNpie7sGZv8u2LhA+Znby2C4h3bwWNV/d0p7ped4xrQY5
yVpZEUbYVdcOOYBgeBJlfwOhvjRQTdxeK4d7W9XTb+AQf30F3DgSepdMCdf3BjVt
KnQvBOTxyidB8xsCL46wlxxNew3qoUtaKoY88WUOOnnJwU5U7hlRtPkf/eO2i5QF
+k7fxUpFfkBTS4I2gXnyGWpmSoxwJerd0knojSOjrjJcAlcgM65+pocUAea/0Dpr
SsfL2sTb12gk6bkF9UlRv8/4aSsWYb92WW1nbTt2nFRXncPNN5Qzc3lGj//36O+b
2bka+aSKVAFoNAnQ1pUE8EJxSboy5q7y4509iZzO/Fom+pVuzBROm5fmrpcOE5dP
IjW7gqSFB6578tnNiK049rrrPja5wkUa+Ptc8s0FjPAVyIDrp2RN+f2nljOBBhW8
3Z1nXMG0eFqvb5taLtfZ
=D9QX
-----END PGP SIGNATURE-----
Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull SCSI updates from James Bottomley:
"This is mostly updates of the usual suspects: lpfc, qla2xxx, bnx2fc,
qedf, hpsa, hisi_sas, smartpqi, cxlflash, aacraid, csiostor along with
a host of minor and miscellaneous changes"
* tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (276 commits)
qla2xxx: Fix NVMe entry_type for iocb packet on BE system
scsi: qla2xxx: avoid unused-function warning
scsi: snic: fix a couple of spelling mistakes/typos
scsi: qla2xxx: fix a bunch of typos and spelling mistakes
scsi: lpfc: don't double count abort errors
scsi: lpfc: spin_lock_irq() is not nestable
scsi: hisi_sas: optimise DMA slot memory
scsi: ibmvfc: constify dev_pm_ops structures.
scsi: ibmvscsi: constify dev_pm_ops structures.
scsi: cxlflash: Update debug prints in reset handlers
scsi: cxlflash: Update send_tmf() parameters
scsi: cxlflash: Avoid double free of character device
scsi: Add STARGET_CREATED_REMOVE state to scsi_target_state
scsi: ses: do not add a device to an enclosure if enclosure_add_links() fails.
scsi: ufs: flush eh_work when eh_work scheduled.
scsi: qla2xxx: Protect access to qpair members with qpair->qp_lock
scsi: sun_esp: fix device reference leaks
scsi: fnic: changing queue command to return result DID_IMM_RETRY when rport is init
scsi: fnic: correct speed display and add support for 25,40 and 100G
scsi: fnic: added timestamp reporting in fnic debug stats
...
2017-07-06 13:10:33 -06:00
|
|
|
* bindings also remain.
|
2005-04-16 16:20:36 -06:00
|
|
|
*
|
|
|
|
* If the remote port is not an FCP Target, it will be fully torn down
|
|
|
|
* and deallocated, including the fc_remote_port class device.
|
|
|
|
*
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
* If the remote port is an FCP Target, the port will be placed in a
|
|
|
|
* temporary blocked state. From the LLDD's perspective, the rport no
|
|
|
|
* longer exists. From the SCSI midlayer's perspective, the SCSI target
|
|
|
|
* exists, but all sdevs on it are blocked from further I/O. The following
|
2007-11-03 12:30:39 -06:00
|
|
|
* is then expected.
|
|
|
|
*
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
* If the remote port does not return (signaled by a LLDD call to
|
|
|
|
* fc_remote_port_add()) within the dev_loss_tmo timeout, then the
|
|
|
|
* scsi target is removed - killing all outstanding i/o and removing the
|
2017-06-21 14:24:39 -06:00
|
|
|
* scsi devices attached to it. The port structure will be marked Not
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
* Present and be partially cleared, leaving only enough information to
|
|
|
|
* recognize the remote port relative to the scsi target id binding if
|
|
|
|
* it later appears. The port will remain as long as there is a valid
|
|
|
|
* binding (e.g. until the user changes the binding type or unloads the
|
|
|
|
* scsi host with the binding).
|
2005-04-16 16:20:36 -06:00
|
|
|
*
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
* If the remote port returns within the dev_loss_tmo value (and matches
|
|
|
|
* according to the target id binding type), the port structure will be
|
|
|
|
* reused. If it is no longer a SCSI target, the target will be torn
|
|
|
|
* down. If it continues to be a SCSI target, then the target will be
|
|
|
|
* unblocked (allowing i/o to be resumed), and a scan will be activated
|
|
|
|
* to ensure that all luns are detected.
|
|
|
|
*
|
|
|
|
* Called from normal process context only - cannot be called from interrupt.
|
2005-04-16 16:20:36 -06:00
|
|
|
*
|
|
|
|
* Notes:
|
|
|
|
* This routine assumes no locks are held on entry.
|
2007-11-03 12:30:39 -06:00
|
|
|
*/
|
2005-04-16 16:20:36 -06:00
|
|
|
void
|
|
|
|
fc_remote_port_delete(struct fc_rport *rport)
|
|
|
|
{
|
2006-04-10 08:14:05 -06:00
|
|
|
struct Scsi_Host *shost = rport_to_shost(rport);
|
2010-03-09 02:18:48 -07:00
|
|
|
unsigned long timeout = rport->dev_loss_tmo;
|
2006-04-10 08:14:05 -06:00
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* No need to flush the fc_host work_q's, as all adds are synchronous.
|
|
|
|
*
|
|
|
|
* We do need to reclaim the rport scan work element, so eventually
|
|
|
|
* (in fc_rport_final_delete()) we'll flush the scsi host work_q if
|
|
|
|
* there's still a scan pending.
|
|
|
|
*/
|
|
|
|
|
|
|
|
spin_lock_irqsave(shost->host_lock, flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2007-04-27 09:53:17 -06:00
|
|
|
if (rport->port_state != FC_PORTSTATE_ONLINE) {
|
2006-04-10 08:14:05 -06:00
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-04-27 09:53:17 -06:00
|
|
|
/*
|
|
|
|
* In the past, we if this was not an FCP-Target, we would
|
|
|
|
* unconditionally just jump to deleting the rport.
|
|
|
|
* However, rports can be used as node containers by the LLDD,
|
|
|
|
* and its not appropriate to just terminate the rport at the
|
|
|
|
* first sign of a loss in connectivity. The LLDD may want to
|
|
|
|
* send ELS traffic to re-validate the login. If the rport is
|
|
|
|
* immediately deleted, it makes it inappropriate for a node
|
|
|
|
* container.
|
|
|
|
* So... we now unconditionally wait dev_loss_tmo before
|
|
|
|
* destroying an rport.
|
|
|
|
*/
|
|
|
|
|
2006-04-10 08:14:05 -06:00
|
|
|
rport->port_state = FC_PORTSTATE_BLOCKED;
|
|
|
|
|
|
|
|
rport->flags |= FC_RPORT_DEVLOSS_PENDING;
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
|
|
|
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
scsi_target_block(&rport->dev);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2006-08-18 15:33:29 -06:00
|
|
|
/* see if we need to kill io faster than waiting for device loss */
|
|
|
|
if ((rport->fast_io_fail_tmo != -1) &&
|
2008-08-19 17:45:23 -06:00
|
|
|
(rport->fast_io_fail_tmo < timeout))
|
2006-08-18 15:33:29 -06:00
|
|
|
fc_queue_devloss_work(shost, &rport->fail_io_work,
|
|
|
|
rport->fast_io_fail_tmo * HZ);
|
|
|
|
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
/* cap the length the devices can be blocked until they are deleted */
|
2006-04-10 08:14:05 -06:00
|
|
|
fc_queue_devloss_work(shost, &rport->dev_loss_work, timeout * HZ);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(fc_remote_port_delete);
|
|
|
|
|
|
|
|
/**
|
2007-11-03 12:30:39 -06:00
|
|
|
* fc_remote_port_rolechg - notifies the fc transport that the roles on a remote may have changed.
|
2005-04-16 16:20:36 -06:00
|
|
|
* @rport: The remote port that changed.
|
2007-11-03 12:30:39 -06:00
|
|
|
* @roles: New roles for this port.
|
2005-04-16 16:20:36 -06:00
|
|
|
*
|
2007-11-03 12:30:39 -06:00
|
|
|
* Description: The LLDD calls this routine to notify the transport that the
|
|
|
|
* roles on a remote port may have changed. The largest effect of this is
|
2005-04-16 16:20:36 -06:00
|
|
|
* if a port now becomes a FCP Target, it must be allocated a
|
|
|
|
* scsi target id. If the port is no longer a FCP target, any
|
|
|
|
* scsi target id value assigned to it will persist in case the
|
|
|
|
* role changes back to include FCP Target. No changes in the scsi
|
|
|
|
* midlayer will be invoked if the role changes (in the expectation
|
|
|
|
* that the role will be resumed. If it doesn't normal error processing
|
|
|
|
* will take place).
|
|
|
|
*
|
|
|
|
* Should not be called from interrupt context.
|
|
|
|
*
|
|
|
|
* Notes:
|
|
|
|
* This routine assumes no locks are held on entry.
|
2007-11-03 12:30:39 -06:00
|
|
|
*/
|
2005-04-16 16:20:36 -06:00
|
|
|
void
|
|
|
|
fc_remote_port_rolechg(struct fc_rport *rport, u32 roles)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = rport_to_shost(rport);
|
2006-04-10 08:14:05 -06:00
|
|
|
struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
|
2005-04-16 16:20:36 -06:00
|
|
|
unsigned long flags;
|
|
|
|
int create = 0;
|
|
|
|
|
|
|
|
spin_lock_irqsave(shost->host_lock, flags);
|
2007-04-27 10:41:09 -06:00
|
|
|
if (roles & FC_PORT_ROLE_FCP_TARGET) {
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
if (rport->scsi_target_id == -1) {
|
|
|
|
rport->scsi_target_id = fc_host->next_target_id++;
|
|
|
|
create = 1;
|
2007-04-27 10:41:09 -06:00
|
|
|
} else if (!(rport->roles & FC_PORT_ROLE_FCP_TARGET))
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
create = 1;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
rport->roles = roles;
|
|
|
|
|
2006-04-10 08:14:05 -06:00
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
|
|
|
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
if (create) {
|
|
|
|
/*
|
|
|
|
* There may have been a delete timer running on the
|
|
|
|
* port. Ensure that it is cancelled as we now know
|
|
|
|
* the port is an FCP Target.
|
2017-06-21 14:24:39 -06:00
|
|
|
* Note: we know the rport exists and is in an online
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
* state as the LLDD would not have had an rport
|
|
|
|
* reference to pass us.
|
|
|
|
*
|
|
|
|
* Take no action on the del_timer failure as the state
|
|
|
|
* machine state change will validate the
|
|
|
|
* transaction.
|
|
|
|
*/
|
2006-08-18 15:33:29 -06:00
|
|
|
if (!cancel_delayed_work(&rport->fail_io_work))
|
|
|
|
fc_flush_devloss(shost);
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
if (!cancel_delayed_work(&rport->dev_loss_work))
|
2006-04-10 08:14:05 -06:00
|
|
|
fc_flush_devloss(shost);
|
|
|
|
|
|
|
|
spin_lock_irqsave(shost->host_lock, flags);
|
2008-08-19 17:45:23 -06:00
|
|
|
rport->flags &= ~(FC_RPORT_FAST_FAIL_TIMEDOUT |
|
[SCSI] scsi_transport_fc: Clear Devloss Callback Done flag in fc_remote_port_rolechg
This patch fixes a bug where devloss is not called on fc_host teardown.
The issue is seen if the LLDD uses rport_rolechg to add the target role
to an rport.
When an rport goes away, the LLDD will call fc_remote_port_delete, which
will start the devloss timer. If the timer expires, the transport will
call the devloss callback and set the FC_RPORT_DEVLOSS_CALLBK_DONE flag.
However, the rport structure is not deleted, it is retained to store the
SCSI id mappings for the rport in case it comes back. In the scenario
where it does come back, and the driver calls fc_remote_port_add, but does
not indicate the "target" role for the rport - the create will clear the
structure, but forgets to clear FC_RPORT_DEVLOSS_CALLBK_DONE flag (which
is cleared if it's added with the target role). The secondary call, of
fc_remote_port_rolechg to add the target role also does not clear the flag.
Thus, the next time the rport goes away, the resulting devloss timer
expiration will not call the driver callback as the flag is still set.
This patch adds the FC_RPORT_DEVLOSS_CALLBK_DONE flags to the list of
those that are cleared upon reuse of the rport structure.
Signed-off-by: Alex Iannicelli <alex.iannicelli@emulex.com>
Signed-off-by: James Smart <james.smart@emulex.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2011-11-03 09:10:40 -06:00
|
|
|
FC_RPORT_DEVLOSS_PENDING |
|
|
|
|
FC_RPORT_DEVLOSS_CALLBK_DONE);
|
2006-04-10 08:14:05 -06:00
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
|
|
|
|
|
|
|
/* ensure any stgt delete functions are done */
|
|
|
|
fc_flush_work(shost);
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
|
2012-05-17 22:56:57 -06:00
|
|
|
scsi_target_unblock(&rport->dev, SDEV_RUNNING);
|
2005-04-16 16:20:36 -06:00
|
|
|
/* initiate a scan of the target */
|
2006-04-10 08:14:05 -06:00
|
|
|
spin_lock_irqsave(shost->host_lock, flags);
|
|
|
|
rport->flags |= FC_RPORT_SCAN_PENDING;
|
2005-04-16 16:20:36 -06:00
|
|
|
scsi_queue_work(shost, &rport->scan_work);
|
2006-04-10 08:14:05 -06:00
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(fc_remote_port_rolechg);
|
|
|
|
|
|
|
|
/**
|
2007-11-03 12:30:39 -06:00
|
|
|
* fc_timeout_deleted_rport - Timeout handler for a deleted remote port.
|
2007-04-27 09:53:17 -06:00
|
|
|
* @work: rport target that failed to reappear in the allotted time.
|
2007-11-03 12:30:39 -06:00
|
|
|
*
|
|
|
|
* Description: An attempt to delete a remote port blocks, and if it fails
|
|
|
|
* to return in the allotted time this gets called.
|
|
|
|
*/
|
2005-04-16 16:20:36 -06:00
|
|
|
static void
|
2006-11-22 07:57:56 -07:00
|
|
|
fc_timeout_deleted_rport(struct work_struct *work)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2006-11-22 07:57:56 -07:00
|
|
|
struct fc_rport *rport =
|
|
|
|
container_of(work, struct fc_rport, dev_loss_work.work);
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
struct Scsi_Host *shost = rport_to_shost(rport);
|
2009-01-05 10:14:18 -07:00
|
|
|
struct fc_internal *i = to_fc_internal(shost->transportt);
|
2006-04-10 08:14:05 -06:00
|
|
|
struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
unsigned long flags;
|
2009-10-09 13:15:59 -06:00
|
|
|
int do_callback = 0;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
spin_lock_irqsave(shost->host_lock, flags);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2006-04-10 08:14:05 -06:00
|
|
|
rport->flags &= ~FC_RPORT_DEVLOSS_PENDING;
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
2007-04-27 09:53:17 -06:00
|
|
|
* If the port is ONLINE, then it came back. If it was a SCSI
|
|
|
|
* target, validate it still is. If not, tear down the
|
|
|
|
* scsi_target on it.
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
2006-04-10 08:14:05 -06:00
|
|
|
if ((rport->port_state == FC_PORTSTATE_ONLINE) &&
|
2007-04-27 09:53:17 -06:00
|
|
|
(rport->scsi_target_id != -1) &&
|
2007-04-27 10:41:09 -06:00
|
|
|
!(rport->roles & FC_PORT_ROLE_FCP_TARGET)) {
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
dev_printk(KERN_ERR, &rport->dev,
|
2006-04-10 08:14:05 -06:00
|
|
|
"blocked FC remote port time out: no longer"
|
|
|
|
" a FCP target, removing starget\n");
|
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
2012-05-17 22:56:57 -06:00
|
|
|
scsi_target_unblock(&rport->dev, SDEV_TRANSPORT_OFFLINE);
|
[SCSI] fc transport: resolve scan vs delete deadlocks
In a prior posting to linux-scsi on the fc transport and workq
deadlocks, we noted a second error that did not have a patch:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114467847711383&w=2
- There's a deadlock where scsi_remove_target() has to sit behind
scsi_scan_target() due to contention over the scan_lock().
Subsequently we posted a request for comments about the deadlock:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114469358829500&w=2
This posting resolves the second error. Here's what we now understand,
and are implementing:
If the lldd deletes the rport while a scan is active, the sdev's queue
is blocked which stops the issuing of commands associated with the scan.
At this point, the scan stalls, and does so with the shost->scan_mutex held.
If, at this point, if any scan or delete request is made on the host, it
will stall waiting for the scan_mutex.
For the FC transport, we queue all delete work to a single workq.
So, things worked fine when competing with the scan, as long as the
target blocking the scan was the same target at the top of our delete
workq, as the delete workq routine always unblocked just prior to
requesting the delete. Unfortunately, if the top of our delete workq
was for a different target, we deadlock. Additionally, if the target
blocking scan returned, we were unblocking it in the scan workq routine,
which really won't execute until the existing stalled scan workq
completes (e.g. we're re-scheduling it while it is in the midst of its
execution).
This patch moves the unblock out of the workq routines and moves it to
the context that is scheduling the work. This ensures that at some point,
we will unblock the target that is blocking scan. Please note, however,
that the deadlock condition may still occur while it waits for the
transport to timeout an unblock on a target. Worst case, this is bounded
by the transport dev_loss_tmo (default: 30 seconds).
Finally, Michael Reed deserves the credit for the bulk of this patch,
analysis, and it's testing. Thank you for your help.
Note: The request for comments statements about the gross-ness of the
scan_mutex still stand.
Signed-off-by: Michael Reed <mdr@sgi.com>
Signed-off-by: James Smart <james.smart@emulex.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-05-11 11:27:09 -06:00
|
|
|
fc_queue_work(shost, &rport->stgt_delete_work);
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
return;
|
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2007-04-27 09:53:17 -06:00
|
|
|
/* NOOP state - we're flushing workq's */
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
if (rport->port_state != FC_PORTSTATE_BLOCKED) {
|
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
|
|
|
dev_printk(KERN_ERR, &rport->dev,
|
2007-04-27 09:53:17 -06:00
|
|
|
"blocked FC remote port time out: leaving"
|
|
|
|
" rport%s alone\n",
|
|
|
|
(rport->scsi_target_id != -1) ? " and starget" : "");
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
return;
|
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2007-04-27 09:53:17 -06:00
|
|
|
if ((fc_host->tgtid_bind_type == FC_TGTID_BIND_NONE) ||
|
|
|
|
(rport->scsi_target_id == -1)) {
|
2006-04-10 08:14:05 -06:00
|
|
|
list_del(&rport->peers);
|
|
|
|
rport->port_state = FC_PORTSTATE_DELETED;
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
dev_printk(KERN_ERR, &rport->dev,
|
2007-04-27 09:53:17 -06:00
|
|
|
"blocked FC remote port time out: removing"
|
|
|
|
" rport%s\n",
|
|
|
|
(rport->scsi_target_id != -1) ? " and starget" : "");
|
2006-04-10 08:14:05 -06:00
|
|
|
fc_queue_work(shost, &rport->rport_delete_work);
|
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
return;
|
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
dev_printk(KERN_ERR, &rport->dev,
|
|
|
|
"blocked FC remote port time out: removing target and "
|
|
|
|
"saving binding\n");
|
|
|
|
|
2006-04-10 08:14:05 -06:00
|
|
|
list_move_tail(&rport->peers, &fc_host->rport_bindings);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/*
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
* Note: We do not remove or clear the hostdata area. This allows
|
|
|
|
* host-specific target data to persist along with the
|
|
|
|
* scsi_target_id. It's up to the host to manage it's hostdata area.
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
|
|
|
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
/*
|
|
|
|
* Reinitialize port attributes that may change if the port comes back.
|
|
|
|
*/
|
|
|
|
rport->maxframe_size = -1;
|
|
|
|
rport->supported_classes = FC_COS_UNSPECIFIED;
|
2007-04-27 10:41:09 -06:00
|
|
|
rport->roles = FC_PORT_ROLE_UNKNOWN;
|
2006-04-10 08:14:05 -06:00
|
|
|
rport->port_state = FC_PORTSTATE_NOTPRESENT;
|
2008-08-19 17:45:23 -06:00
|
|
|
rport->flags &= ~FC_RPORT_FAST_FAIL_TIMEDOUT;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2008-12-05 15:29:59 -07:00
|
|
|
/*
|
|
|
|
* Pre-emptively kill I/O rather than waiting for the work queue
|
|
|
|
* item to teardown the starget. (FCOE libFC folks prefer this
|
|
|
|
* and to have the rport_port_id still set when it's done).
|
|
|
|
*/
|
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
|
|
|
fc_terminate_rport_io(rport);
|
|
|
|
|
2009-10-09 13:15:59 -06:00
|
|
|
spin_lock_irqsave(shost->host_lock, flags);
|
|
|
|
|
|
|
|
if (rport->port_state == FC_PORTSTATE_NOTPRESENT) { /* still missing */
|
2008-12-05 15:29:59 -07:00
|
|
|
|
2009-10-09 13:15:59 -06:00
|
|
|
/* remove the identifiers that aren't used in the consisting binding */
|
|
|
|
switch (fc_host->tgtid_bind_type) {
|
|
|
|
case FC_TGTID_BIND_BY_WWPN:
|
|
|
|
rport->node_name = -1;
|
|
|
|
rport->port_id = -1;
|
|
|
|
break;
|
|
|
|
case FC_TGTID_BIND_BY_WWNN:
|
|
|
|
rport->port_name = -1;
|
|
|
|
rport->port_id = -1;
|
|
|
|
break;
|
|
|
|
case FC_TGTID_BIND_BY_ID:
|
|
|
|
rport->node_name = -1;
|
|
|
|
rport->port_name = -1;
|
|
|
|
break;
|
|
|
|
case FC_TGTID_BIND_NONE: /* to keep compiler happy */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* As this only occurs if the remote port (scsi target)
|
|
|
|
* went away and didn't come back - we'll remove
|
|
|
|
* all attached scsi devices.
|
|
|
|
*/
|
|
|
|
rport->flags |= FC_RPORT_DEVLOSS_CALLBK_DONE;
|
|
|
|
fc_queue_work(shost, &rport->stgt_delete_work);
|
|
|
|
|
|
|
|
do_callback = 1;
|
[SCSI] update fc_transport for removal of block/unblock functions
We recently went back to implement a board reset. When we perform the
reset, we wanted to tear down the internal data structures and rebuild
them. Unfortunately, when it came to the rport structure, things were
odd. If we deleted them, the scsi targets and sdevs would be
torn down. Not a good thing for a temporary reset. We could block the
rports, but we either maintain the internal structures to keep the
rport reference (perhaps even replicating what's in the transport),
or we have to fatten the fc transport with new search routines to find
the rport (and deal with a case of a dangling rport that the driver
forgets).
It dawned on me that we had actually reached this state incorrectly.
When the fc transport first started, we did the block/unblock first, then
added the rport interface. The purpose of block/unblock is to hide the
temporary disappearance of the rport (e.g. being deleted, then readded).
Why are we making the driver do the block/unblock ? We should be making
the transport have only an rport add/delete, and the let the transport
handle the block/unblock.
So... This patch removes the existing fc_remote_port_block/unblock
functions. It moves the block/unblock functionality into the
fc_remote_port_add/delete functions. Updates for the lpfc driver are
included. Qlogic driver updates are also enclosed, thanks to the
contributions of Andrew Vasquez. [Note: the qla2xxx changes are
relative to the scsi-misc-2.6 tree as of this morning - which does
not include the recent patches sent by Andrew]. The zfcp driver does
not use the block/unblock functions.
One last comment: The resulting behavior feels very clean. The LLDD is
concerned only with add/delete, which corresponds to the physical
disappearance. However, the fact that the scsi target and sdevs are
not immediately torn down after the LLDD calls delete causes an
interesting scenario... the midlayer can call the xxx_slave_alloc and
xxx_queuecommand functions with a sdev that is at the location the
rport used to be. The driver must validate the device exists when it
first enters these functions. In thinking about it, this has always
been the case for the LLDD and these routines. The existing drivers
already check for existence. However, this highlights that simple
validation via data structure dereferencing needs to be watched.
To deal with this, a new transport function, fc_remote_port_chkready()
was created that LLDDs should call when they first enter these two
routines. It validates the rport state, and returns a scsi result
which could be returned. In addition to solving the above, it also
creates consistent behavior from the LLDD's when the block and deletes
are occuring.
Rejections fixed up and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-10-18 10:03:35 -06:00
|
|
|
}
|
|
|
|
|
2009-10-09 13:15:59 -06:00
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
2009-01-05 10:14:18 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Notify the driver that the rport is now dead. The LLDD will
|
|
|
|
* also guarantee that any communication to the rport is terminated
|
|
|
|
*
|
|
|
|
* Note: we set the CALLBK_DONE flag above to correspond
|
|
|
|
*/
|
2009-10-09 13:15:59 -06:00
|
|
|
if (do_callback && i->f->dev_loss_tmo_callbk)
|
2009-01-05 10:14:18 -07:00
|
|
|
i->f->dev_loss_tmo_callbk(rport);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2009-01-05 10:14:18 -07:00
|
|
|
|
2006-08-18 15:33:29 -06:00
|
|
|
/**
|
2007-11-03 12:30:39 -06:00
|
|
|
* fc_timeout_fail_rport_io - Timeout handler for a fast io failing on a disconnected SCSI target.
|
2006-11-22 07:57:56 -07:00
|
|
|
* @work: rport to terminate io on.
|
2006-08-18 15:33:29 -06:00
|
|
|
*
|
|
|
|
* Notes: Only requests the failure of the io, not that all are flushed
|
|
|
|
* prior to returning.
|
2007-11-03 12:30:39 -06:00
|
|
|
*/
|
2006-08-18 15:33:29 -06:00
|
|
|
static void
|
2006-11-22 07:57:56 -07:00
|
|
|
fc_timeout_fail_rport_io(struct work_struct *work)
|
2006-08-18 15:33:29 -06:00
|
|
|
{
|
2006-11-22 07:57:56 -07:00
|
|
|
struct fc_rport *rport =
|
|
|
|
container_of(work, struct fc_rport, fail_io_work.work);
|
2006-08-18 15:33:29 -06:00
|
|
|
|
|
|
|
if (rport->port_state != FC_PORTSTATE_BLOCKED)
|
|
|
|
return;
|
|
|
|
|
2008-08-19 17:45:23 -06:00
|
|
|
rport->flags |= FC_RPORT_FAST_FAIL_TIMEDOUT;
|
|
|
|
fc_terminate_rport_io(rport);
|
2006-08-18 15:33:29 -06:00
|
|
|
}
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/**
|
|
|
|
* fc_scsi_scan_rport - called to perform a scsi scan on a remote port.
|
2006-11-22 07:57:56 -07:00
|
|
|
* @work: remote port to be scanned.
|
2007-11-03 12:30:39 -06:00
|
|
|
*/
|
2005-04-16 16:20:36 -06:00
|
|
|
static void
|
2006-11-22 07:57:56 -07:00
|
|
|
fc_scsi_scan_rport(struct work_struct *work)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2006-11-22 07:57:56 -07:00
|
|
|
struct fc_rport *rport =
|
|
|
|
container_of(work, struct fc_rport, scan_work);
|
2006-04-10 08:14:05 -06:00
|
|
|
struct Scsi_Host *shost = rport_to_shost(rport);
|
2007-08-28 01:31:21 -06:00
|
|
|
struct fc_internal *i = to_fc_internal(shost->transportt);
|
2005-12-15 07:56:22 -07:00
|
|
|
unsigned long flags;
|
|
|
|
|
2006-04-10 08:14:05 -06:00
|
|
|
if ((rport->port_state == FC_PORTSTATE_ONLINE) &&
|
2007-08-28 01:31:21 -06:00
|
|
|
(rport->roles & FC_PORT_ROLE_FCP_TARGET) &&
|
|
|
|
!(i->f->disable_target_scan)) {
|
2006-04-10 08:14:05 -06:00
|
|
|
scsi_scan_target(&rport->dev, rport->channel,
|
2016-03-17 01:39:45 -06:00
|
|
|
rport->scsi_target_id, SCAN_WILD_CARD,
|
|
|
|
SCSI_SCAN_RESCAN);
|
2005-12-15 07:56:22 -07:00
|
|
|
}
|
2006-04-10 08:14:05 -06:00
|
|
|
|
|
|
|
spin_lock_irqsave(shost->host_lock, flags);
|
|
|
|
rport->flags &= ~FC_RPORT_SCAN_PENDING;
|
2005-12-15 07:56:22 -07:00
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
|
|
|
}
|
|
|
|
|
2009-10-30 10:59:29 -06:00
|
|
|
/**
|
|
|
|
* fc_block_scsi_eh - Block SCSI eh thread for blocked fc_rport
|
|
|
|
* @cmnd: SCSI command that scsi_eh is trying to recover
|
|
|
|
*
|
|
|
|
* This routine can be called from a FC LLD scsi_eh callback. It
|
|
|
|
* blocks the scsi_eh thread until the fc_rport leaves the
|
2010-03-24 09:50:30 -06:00
|
|
|
* FC_PORTSTATE_BLOCKED, or the fast_io_fail_tmo fires. This is
|
|
|
|
* necessary to avoid the scsi_eh failing recovery actions for blocked
|
|
|
|
* rports which would lead to offlined SCSI devices.
|
|
|
|
*
|
|
|
|
* Returns: 0 if the fc_rport left the state FC_PORTSTATE_BLOCKED.
|
|
|
|
* FAST_IO_FAIL if the fast_io_fail_tmo fired, this should be
|
|
|
|
* passed back to scsi_eh.
|
2009-10-30 10:59:29 -06:00
|
|
|
*/
|
2010-03-24 09:50:30 -06:00
|
|
|
int fc_block_scsi_eh(struct scsi_cmnd *cmnd)
|
2009-10-30 10:59:29 -06:00
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = cmnd->device->host;
|
|
|
|
struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device));
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(shost->host_lock, flags);
|
2010-03-24 09:50:30 -06:00
|
|
|
while (rport->port_state == FC_PORTSTATE_BLOCKED &&
|
|
|
|
!(rport->flags & FC_RPORT_FAST_FAIL_TIMEDOUT)) {
|
2009-10-30 10:59:29 -06:00
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
|
|
|
msleep(1000);
|
|
|
|
spin_lock_irqsave(shost->host_lock, flags);
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
2010-03-24 09:50:30 -06:00
|
|
|
|
|
|
|
if (rport->flags & FC_RPORT_FAST_FAIL_TIMEDOUT)
|
|
|
|
return FAST_IO_FAIL;
|
|
|
|
|
|
|
|
return 0;
|
2009-10-30 10:59:29 -06:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(fc_block_scsi_eh);
|
2005-12-15 07:56:22 -07:00
|
|
|
|
2007-04-27 10:41:09 -06:00
|
|
|
/**
|
2008-07-18 09:32:52 -06:00
|
|
|
* fc_vport_setup - allocates and creates a FC virtual port.
|
2007-04-27 10:41:09 -06:00
|
|
|
* @shost: scsi host the virtual port is connected to.
|
|
|
|
* @channel: Channel on shost port connected to.
|
|
|
|
* @pdev: parent device for vport
|
|
|
|
* @ids: The world wide names, FC4 port roles, etc for
|
|
|
|
* the virtual port.
|
|
|
|
* @ret_vport: The pointer to the created vport.
|
|
|
|
*
|
|
|
|
* Allocates and creates the vport structure, calls the parent host
|
2017-06-21 14:24:39 -06:00
|
|
|
* to instantiate the vport, this completes w/ class and sysfs creation.
|
2007-04-27 10:41:09 -06:00
|
|
|
*
|
|
|
|
* Notes:
|
|
|
|
* This routine assumes no locks are held on entry.
|
2007-11-03 12:30:39 -06:00
|
|
|
*/
|
2007-04-27 10:41:09 -06:00
|
|
|
static int
|
2008-07-18 09:32:52 -06:00
|
|
|
fc_vport_setup(struct Scsi_Host *shost, int channel, struct device *pdev,
|
2007-04-27 10:41:09 -06:00
|
|
|
struct fc_vport_identifiers *ids, struct fc_vport **ret_vport)
|
|
|
|
{
|
|
|
|
struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
|
|
|
|
struct fc_internal *fci = to_fc_internal(shost->transportt);
|
|
|
|
struct fc_vport *vport;
|
|
|
|
struct device *dev;
|
|
|
|
unsigned long flags;
|
|
|
|
size_t size;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
*ret_vport = NULL;
|
|
|
|
|
|
|
|
if ( ! fci->f->vport_create)
|
|
|
|
return -ENOENT;
|
|
|
|
|
|
|
|
size = (sizeof(struct fc_vport) + fci->f->dd_fcvport_size);
|
|
|
|
vport = kzalloc(size, GFP_KERNEL);
|
|
|
|
if (unlikely(!vport)) {
|
2008-07-04 00:47:27 -06:00
|
|
|
printk(KERN_ERR "%s: allocation failure\n", __func__);
|
2007-04-27 10:41:09 -06:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
vport->vport_state = FC_VPORT_UNKNOWN;
|
|
|
|
vport->vport_last_state = FC_VPORT_UNKNOWN;
|
|
|
|
vport->node_name = ids->node_name;
|
|
|
|
vport->port_name = ids->port_name;
|
|
|
|
vport->roles = ids->roles;
|
|
|
|
vport->vport_type = ids->vport_type;
|
|
|
|
if (fci->f->dd_fcvport_size)
|
|
|
|
vport->dd_data = &vport[1];
|
|
|
|
vport->shost = shost;
|
|
|
|
vport->channel = channel;
|
|
|
|
vport->flags = FC_VPORT_CREATING;
|
2007-05-24 17:04:44 -06:00
|
|
|
INIT_WORK(&vport->vport_delete_work, fc_vport_sched_delete);
|
2007-04-27 10:41:09 -06:00
|
|
|
|
|
|
|
spin_lock_irqsave(shost->host_lock, flags);
|
|
|
|
|
|
|
|
if (fc_host->npiv_vports_inuse >= fc_host->max_npiv_vports) {
|
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
|
|
|
kfree(vport);
|
|
|
|
return -ENOSPC;
|
|
|
|
}
|
|
|
|
fc_host->npiv_vports_inuse++;
|
|
|
|
vport->number = fc_host->next_vport_number++;
|
|
|
|
list_add_tail(&vport->peers, &fc_host->vports);
|
2015-11-20 14:33:04 -07:00
|
|
|
scsi_host_get(shost); /* for fc_host->vport list */
|
2007-04-27 10:41:09 -06:00
|
|
|
|
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
|
|
|
|
|
|
|
dev = &vport->dev;
|
|
|
|
device_initialize(dev); /* takes self reference */
|
|
|
|
dev->parent = get_device(pdev); /* takes parent reference */
|
|
|
|
dev->release = fc_vport_dev_release;
|
2008-12-03 14:41:36 -07:00
|
|
|
dev_set_name(dev, "vport-%d:%d-%d",
|
|
|
|
shost->host_no, channel, vport->number);
|
2007-04-27 10:41:09 -06:00
|
|
|
transport_setup_device(dev);
|
|
|
|
|
|
|
|
error = device_add(dev);
|
|
|
|
if (error) {
|
|
|
|
printk(KERN_ERR "FC Virtual Port device_add failed\n");
|
|
|
|
goto delete_vport;
|
|
|
|
}
|
|
|
|
transport_add_device(dev);
|
|
|
|
transport_configure_device(dev);
|
|
|
|
|
|
|
|
error = fci->f->vport_create(vport, ids->disable);
|
|
|
|
if (error) {
|
|
|
|
printk(KERN_ERR "FC Virtual Port LLDD Create failed\n");
|
|
|
|
goto delete_vport_all;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* if the parent isn't the physical adapter's Scsi_Host, ensure
|
2017-06-21 14:24:39 -06:00
|
|
|
* the Scsi_Host at least contains a symlink to the vport.
|
2007-04-27 10:41:09 -06:00
|
|
|
*/
|
|
|
|
if (pdev != &shost->shost_gendev) {
|
|
|
|
error = sysfs_create_link(&shost->shost_gendev.kobj,
|
2008-12-03 14:41:36 -07:00
|
|
|
&dev->kobj, dev_name(dev));
|
2007-04-27 10:41:09 -06:00
|
|
|
if (error)
|
|
|
|
printk(KERN_ERR
|
|
|
|
"%s: Cannot create vport symlinks for "
|
|
|
|
"%s, err=%d\n",
|
2008-12-03 14:41:36 -07:00
|
|
|
__func__, dev_name(dev), error);
|
2007-04-27 10:41:09 -06:00
|
|
|
}
|
|
|
|
spin_lock_irqsave(shost->host_lock, flags);
|
|
|
|
vport->flags &= ~FC_VPORT_CREATING;
|
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
|
|
|
|
|
|
|
dev_printk(KERN_NOTICE, pdev,
|
2008-12-03 14:41:36 -07:00
|
|
|
"%s created via shost%d channel %d\n", dev_name(dev),
|
2007-04-27 10:41:09 -06:00
|
|
|
shost->host_no, channel);
|
|
|
|
|
|
|
|
*ret_vport = vport;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
delete_vport_all:
|
|
|
|
transport_remove_device(dev);
|
|
|
|
device_del(dev);
|
|
|
|
delete_vport:
|
|
|
|
transport_destroy_device(dev);
|
|
|
|
spin_lock_irqsave(shost->host_lock, flags);
|
|
|
|
list_del(&vport->peers);
|
2015-11-20 14:33:04 -07:00
|
|
|
scsi_host_put(shost); /* for fc_host->vport list */
|
2007-04-27 10:41:09 -06:00
|
|
|
fc_host->npiv_vports_inuse--;
|
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
|
|
|
put_device(dev->parent);
|
|
|
|
kfree(vport);
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2008-07-18 09:32:52 -06:00
|
|
|
/**
|
|
|
|
* fc_vport_create - Admin App or LLDD requests creation of a vport
|
|
|
|
* @shost: scsi host the virtual port is connected to.
|
|
|
|
* @channel: channel on shost port connected to.
|
|
|
|
* @ids: The world wide names, FC4 port roles, etc for
|
|
|
|
* the virtual port.
|
|
|
|
*
|
|
|
|
* Notes:
|
|
|
|
* This routine assumes no locks are held on entry.
|
|
|
|
*/
|
|
|
|
struct fc_vport *
|
|
|
|
fc_vport_create(struct Scsi_Host *shost, int channel,
|
|
|
|
struct fc_vport_identifiers *ids)
|
|
|
|
{
|
|
|
|
int stat;
|
|
|
|
struct fc_vport *vport;
|
|
|
|
|
|
|
|
stat = fc_vport_setup(shost, channel, &shost->shost_gendev,
|
|
|
|
ids, &vport);
|
|
|
|
return stat ? NULL : vport;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(fc_vport_create);
|
2007-04-27 10:41:09 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* fc_vport_terminate - Admin App or LLDD requests termination of a vport
|
|
|
|
* @vport: fc_vport to be terminated
|
|
|
|
*
|
|
|
|
* Calls the LLDD vport_delete() function, then deallocates and removes
|
|
|
|
* the vport from the shost and object tree.
|
|
|
|
*
|
|
|
|
* Notes:
|
|
|
|
* This routine assumes no locks are held on entry.
|
2007-11-03 12:30:39 -06:00
|
|
|
*/
|
2007-04-27 10:41:09 -06:00
|
|
|
int
|
|
|
|
fc_vport_terminate(struct fc_vport *vport)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = vport_to_shost(vport);
|
|
|
|
struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
|
|
|
|
struct fc_internal *i = to_fc_internal(shost->transportt);
|
|
|
|
struct device *dev = &vport->dev;
|
|
|
|
unsigned long flags;
|
|
|
|
int stat;
|
|
|
|
|
|
|
|
if (i->f->vport_delete)
|
|
|
|
stat = i->f->vport_delete(vport);
|
|
|
|
else
|
|
|
|
stat = -ENOENT;
|
|
|
|
|
|
|
|
spin_lock_irqsave(shost->host_lock, flags);
|
|
|
|
vport->flags &= ~FC_VPORT_DELETING;
|
|
|
|
if (!stat) {
|
|
|
|
vport->flags |= FC_VPORT_DELETED;
|
|
|
|
list_del(&vport->peers);
|
|
|
|
fc_host->npiv_vports_inuse--;
|
2015-11-20 14:33:04 -07:00
|
|
|
scsi_host_put(shost); /* for fc_host->vport list */
|
2007-04-27 10:41:09 -06:00
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(shost->host_lock, flags);
|
|
|
|
|
|
|
|
if (stat)
|
|
|
|
return stat;
|
|
|
|
|
|
|
|
if (dev->parent != &shost->shost_gendev)
|
2008-12-03 14:41:36 -07:00
|
|
|
sysfs_remove_link(&shost->shost_gendev.kobj, dev_name(dev));
|
2007-04-27 10:41:09 -06:00
|
|
|
transport_remove_device(dev);
|
|
|
|
device_del(dev);
|
|
|
|
transport_destroy_device(dev);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Removing our self-reference should mean our
|
|
|
|
* release function gets called, which will drop the remaining
|
|
|
|
* parent reference and free the data structure.
|
|
|
|
*/
|
|
|
|
put_device(dev); /* for self-reference */
|
|
|
|
|
|
|
|
return 0; /* SUCCESS */
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(fc_vport_terminate);
|
|
|
|
|
2007-05-24 17:04:44 -06:00
|
|
|
/**
|
|
|
|
* fc_vport_sched_delete - workq-based delete request for a vport
|
|
|
|
* @work: vport to be deleted.
|
2007-11-03 12:30:39 -06:00
|
|
|
*/
|
2007-05-24 17:04:44 -06:00
|
|
|
static void
|
|
|
|
fc_vport_sched_delete(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct fc_vport *vport =
|
|
|
|
container_of(work, struct fc_vport, vport_delete_work);
|
|
|
|
int stat;
|
|
|
|
|
|
|
|
stat = fc_vport_terminate(vport);
|
|
|
|
if (stat)
|
|
|
|
dev_printk(KERN_ERR, vport->dev.parent,
|
|
|
|
"%s: %s could not be deleted created via "
|
2008-07-04 00:47:27 -06:00
|
|
|
"shost%d channel %d - error %d\n", __func__,
|
2008-12-03 14:41:36 -07:00
|
|
|
dev_name(&vport->dev), vport->shost->host_no,
|
2007-05-24 17:04:44 -06:00
|
|
|
vport->channel, stat);
|
|
|
|
}
|
|
|
|
|
2007-04-27 10:41:09 -06:00
|
|
|
|
2009-03-26 11:33:19 -06:00
|
|
|
/*
|
|
|
|
* BSG support
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fc_bsg_job_timeout - handler for when a bsg request timesout
|
|
|
|
* @req: request that timed out
|
|
|
|
*/
|
|
|
|
static enum blk_eh_timer_return
|
|
|
|
fc_bsg_job_timeout(struct request *req)
|
|
|
|
{
|
2016-11-17 02:31:19 -07:00
|
|
|
struct bsg_job *job = (void *) req->special;
|
2016-11-17 02:31:14 -07:00
|
|
|
struct Scsi_Host *shost = fc_bsg_to_shost(job);
|
2016-11-17 02:31:15 -07:00
|
|
|
struct fc_rport *rport = fc_bsg_to_rport(job);
|
2009-03-26 11:33:19 -06:00
|
|
|
struct fc_internal *i = to_fc_internal(shost->transportt);
|
2016-11-17 02:31:17 -07:00
|
|
|
int err = 0, inflight = 0;
|
2009-03-26 11:33:19 -06:00
|
|
|
|
2016-11-17 02:31:15 -07:00
|
|
|
if (rport && rport->port_state == FC_PORTSTATE_BLOCKED)
|
2009-03-26 11:33:19 -06:00
|
|
|
return BLK_EH_RESET_TIMER;
|
|
|
|
|
2016-11-17 02:31:23 -07:00
|
|
|
inflight = bsg_job_get(job);
|
2009-03-26 11:33:19 -06:00
|
|
|
|
2016-11-17 02:31:17 -07:00
|
|
|
if (inflight && i->f->bsg_timeout) {
|
2009-03-26 11:33:19 -06:00
|
|
|
/* call LLDD to abort the i/o as it has timed out */
|
|
|
|
err = i->f->bsg_timeout(job);
|
2010-01-14 09:19:00 -07:00
|
|
|
if (err == -EAGAIN) {
|
2016-11-17 02:31:23 -07:00
|
|
|
bsg_job_put(job);
|
2010-01-14 09:19:00 -07:00
|
|
|
return BLK_EH_RESET_TIMER;
|
|
|
|
} else if (err)
|
2009-03-26 11:33:19 -06:00
|
|
|
printk(KERN_ERR "ERROR: FC BSG request timeout - LLD "
|
|
|
|
"abort failed with status %d\n", err);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the blk_end_sync_io() doesn't check the error */
|
2016-11-17 02:31:17 -07:00
|
|
|
if (!inflight)
|
2009-06-19 17:26:54 -06:00
|
|
|
return BLK_EH_NOT_HANDLED;
|
|
|
|
else
|
|
|
|
return BLK_EH_HANDLED;
|
2009-03-26 11:33:19 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fc_bsg_host_dispatch - process fc host bsg requests and dispatch to LLDD
|
|
|
|
* @shost: scsi host rport attached to
|
|
|
|
* @job: bsg job to be processed
|
|
|
|
*/
|
2016-11-17 02:31:24 -07:00
|
|
|
static int fc_bsg_host_dispatch(struct Scsi_Host *shost, struct bsg_job *job)
|
2009-03-26 11:33:19 -06:00
|
|
|
{
|
|
|
|
struct fc_internal *i = to_fc_internal(shost->transportt);
|
2016-11-17 02:31:12 -07:00
|
|
|
struct fc_bsg_request *bsg_request = job->request;
|
|
|
|
struct fc_bsg_reply *bsg_reply = job->reply;
|
2009-03-26 11:33:19 -06:00
|
|
|
int cmdlen = sizeof(uint32_t); /* start with length of msgcode */
|
|
|
|
int ret;
|
|
|
|
|
2016-11-17 02:31:12 -07:00
|
|
|
/* check if we really have all the request data needed */
|
|
|
|
if (job->request_len < cmdlen) {
|
|
|
|
ret = -ENOMSG;
|
|
|
|
goto fail_host_msg;
|
|
|
|
}
|
|
|
|
|
2009-03-26 11:33:19 -06:00
|
|
|
/* Validate the host command */
|
2016-11-17 02:31:12 -07:00
|
|
|
switch (bsg_request->msgcode) {
|
2009-03-26 11:33:19 -06:00
|
|
|
case FC_BSG_HST_ADD_RPORT:
|
|
|
|
cmdlen += sizeof(struct fc_bsg_host_add_rport);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FC_BSG_HST_DEL_RPORT:
|
|
|
|
cmdlen += sizeof(struct fc_bsg_host_del_rport);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FC_BSG_HST_ELS_NOLOGIN:
|
|
|
|
cmdlen += sizeof(struct fc_bsg_host_els);
|
|
|
|
/* there better be a xmt and rcv payloads */
|
|
|
|
if ((!job->request_payload.payload_len) ||
|
|
|
|
(!job->reply_payload.payload_len)) {
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto fail_host_msg;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FC_BSG_HST_CT:
|
|
|
|
cmdlen += sizeof(struct fc_bsg_host_ct);
|
|
|
|
/* there better be xmt and rcv payloads */
|
|
|
|
if ((!job->request_payload.payload_len) ||
|
|
|
|
(!job->reply_payload.payload_len)) {
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto fail_host_msg;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FC_BSG_HST_VENDOR:
|
|
|
|
cmdlen += sizeof(struct fc_bsg_host_vendor);
|
|
|
|
if ((shost->hostt->vendor_id == 0L) ||
|
2016-11-17 02:31:12 -07:00
|
|
|
(bsg_request->rqst_data.h_vendor.vendor_id !=
|
2009-03-26 11:33:19 -06:00
|
|
|
shost->hostt->vendor_id)) {
|
|
|
|
ret = -ESRCH;
|
|
|
|
goto fail_host_msg;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
ret = -EBADR;
|
|
|
|
goto fail_host_msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = i->f->bsg_request(job);
|
|
|
|
if (!ret)
|
2016-11-17 02:31:24 -07:00
|
|
|
return 0;
|
2009-03-26 11:33:19 -06:00
|
|
|
|
|
|
|
fail_host_msg:
|
|
|
|
/* return the errno failure code as the only status */
|
|
|
|
BUG_ON(job->reply_len < sizeof(uint32_t));
|
2016-11-17 02:31:12 -07:00
|
|
|
bsg_reply->reply_payload_rcv_len = 0;
|
|
|
|
bsg_reply->result = ret;
|
2009-03-26 11:33:19 -06:00
|
|
|
job->reply_len = sizeof(uint32_t);
|
2016-11-17 02:31:22 -07:00
|
|
|
bsg_job_done(job, bsg_reply->result,
|
2016-11-17 02:31:13 -07:00
|
|
|
bsg_reply->reply_payload_rcv_len);
|
2016-11-17 02:31:24 -07:00
|
|
|
return 0;
|
2009-03-26 11:33:19 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* fc_bsg_goose_queue - restart rport queue in case it was stopped
|
|
|
|
* @rport: rport to be restarted
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
fc_bsg_goose_queue(struct fc_rport *rport)
|
|
|
|
{
|
2016-11-11 17:55:50 -07:00
|
|
|
struct request_queue *q = rport->rqst_q;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
if (!q)
|
2009-03-26 11:33:19 -06:00
|
|
|
return;
|
|
|
|
|
2016-11-11 17:55:50 -07:00
|
|
|
spin_lock_irqsave(q->queue_lock, flags);
|
|
|
|
blk_run_queue_async(q);
|
|
|
|
spin_unlock_irqrestore(q->queue_lock, flags);
|
2009-03-26 11:33:19 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fc_bsg_rport_dispatch - process rport bsg requests and dispatch to LLDD
|
|
|
|
* @shost: scsi host rport attached to
|
|
|
|
* @job: bsg job to be processed
|
|
|
|
*/
|
2016-11-17 02:31:24 -07:00
|
|
|
static int fc_bsg_rport_dispatch(struct Scsi_Host *shost, struct bsg_job *job)
|
2009-03-26 11:33:19 -06:00
|
|
|
{
|
|
|
|
struct fc_internal *i = to_fc_internal(shost->transportt);
|
2016-11-17 02:31:12 -07:00
|
|
|
struct fc_bsg_request *bsg_request = job->request;
|
|
|
|
struct fc_bsg_reply *bsg_reply = job->reply;
|
2009-03-26 11:33:19 -06:00
|
|
|
int cmdlen = sizeof(uint32_t); /* start with length of msgcode */
|
|
|
|
int ret;
|
|
|
|
|
2016-11-17 02:31:12 -07:00
|
|
|
/* check if we really have all the request data needed */
|
|
|
|
if (job->request_len < cmdlen) {
|
|
|
|
ret = -ENOMSG;
|
|
|
|
goto fail_rport_msg;
|
|
|
|
}
|
|
|
|
|
2009-03-26 11:33:19 -06:00
|
|
|
/* Validate the rport command */
|
2016-11-17 02:31:12 -07:00
|
|
|
switch (bsg_request->msgcode) {
|
2009-03-26 11:33:19 -06:00
|
|
|
case FC_BSG_RPT_ELS:
|
|
|
|
cmdlen += sizeof(struct fc_bsg_rport_els);
|
|
|
|
goto check_bidi;
|
|
|
|
|
|
|
|
case FC_BSG_RPT_CT:
|
|
|
|
cmdlen += sizeof(struct fc_bsg_rport_ct);
|
|
|
|
check_bidi:
|
|
|
|
/* there better be xmt and rcv payloads */
|
|
|
|
if ((!job->request_payload.payload_len) ||
|
|
|
|
(!job->reply_payload.payload_len)) {
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto fail_rport_msg;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = -EBADR;
|
|
|
|
goto fail_rport_msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = i->f->bsg_request(job);
|
|
|
|
if (!ret)
|
2016-11-17 02:31:24 -07:00
|
|
|
return 0;
|
2009-03-26 11:33:19 -06:00
|
|
|
|
|
|
|
fail_rport_msg:
|
|
|
|
/* return the errno failure code as the only status */
|
|
|
|
BUG_ON(job->reply_len < sizeof(uint32_t));
|
2016-11-17 02:31:12 -07:00
|
|
|
bsg_reply->reply_payload_rcv_len = 0;
|
|
|
|
bsg_reply->result = ret;
|
2009-03-26 11:33:19 -06:00
|
|
|
job->reply_len = sizeof(uint32_t);
|
2016-11-17 02:31:22 -07:00
|
|
|
bsg_job_done(job, bsg_reply->result,
|
2016-11-17 02:31:13 -07:00
|
|
|
bsg_reply->reply_payload_rcv_len);
|
2016-11-17 02:31:24 -07:00
|
|
|
return 0;
|
2009-03-26 11:33:19 -06:00
|
|
|
}
|
|
|
|
|
2016-11-17 02:31:24 -07:00
|
|
|
static int fc_bsg_dispatch(struct bsg_job *job)
|
2009-03-26 11:33:19 -06:00
|
|
|
{
|
2016-11-17 02:31:24 -07:00
|
|
|
struct Scsi_Host *shost = fc_bsg_to_shost(job);
|
2009-03-26 11:33:19 -06:00
|
|
|
|
2016-11-17 02:31:24 -07:00
|
|
|
if (scsi_is_fc_rport(job->dev))
|
|
|
|
return fc_bsg_rport_dispatch(shost, job);
|
|
|
|
else
|
|
|
|
return fc_bsg_host_dispatch(shost, job);
|
2009-03-26 11:33:19 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fc_bsg_hostadd - Create and add the bsg hooks so we can receive requests
|
|
|
|
* @shost: shost for fc_host
|
|
|
|
* @fc_host: fc_host adding the structures to
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
fc_bsg_hostadd(struct Scsi_Host *shost, struct fc_host_attrs *fc_host)
|
|
|
|
{
|
|
|
|
struct device *dev = &shost->shost_gendev;
|
|
|
|
struct fc_internal *i = to_fc_internal(shost->transportt);
|
|
|
|
struct request_queue *q;
|
2009-06-21 11:11:43 -06:00
|
|
|
char bsg_name[20];
|
2009-03-26 11:33:19 -06:00
|
|
|
|
|
|
|
fc_host->rqst_q = NULL;
|
|
|
|
|
|
|
|
if (!i->f->bsg_request)
|
|
|
|
return -ENOTSUPP;
|
|
|
|
|
|
|
|
snprintf(bsg_name, sizeof(bsg_name),
|
|
|
|
"fc_host%d", shost->host_no);
|
|
|
|
|
2017-01-03 05:25:02 -07:00
|
|
|
q = bsg_setup_queue(dev, bsg_name, fc_bsg_dispatch, i->f->dd_bsg_size);
|
|
|
|
if (IS_ERR(q)) {
|
2016-11-17 02:31:24 -07:00
|
|
|
dev_err(dev,
|
|
|
|
"fc_host%d: bsg interface failed to initialize - setup queue\n",
|
|
|
|
shost->host_no);
|
2017-01-03 05:25:02 -07:00
|
|
|
return PTR_ERR(q);
|
2009-03-26 11:33:19 -06:00
|
|
|
}
|
2017-01-03 05:25:02 -07:00
|
|
|
__scsi_init_queue(shost, q);
|
2016-11-17 02:31:24 -07:00
|
|
|
blk_queue_rq_timed_out(q, fc_bsg_job_timeout);
|
|
|
|
blk_queue_rq_timeout(q, FC_DEFAULT_BSG_TIMEOUT);
|
2009-03-26 11:33:19 -06:00
|
|
|
fc_host->rqst_q = q;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-11-17 02:31:24 -07:00
|
|
|
static int fc_bsg_rport_prep(struct request_queue *q, struct request *req)
|
|
|
|
{
|
|
|
|
struct fc_rport *rport = dev_to_rport(q->queuedata);
|
|
|
|
|
|
|
|
if (rport->port_state == FC_PORTSTATE_BLOCKED &&
|
|
|
|
!(rport->flags & FC_RPORT_FAST_FAIL_TIMEDOUT))
|
|
|
|
return BLKPREP_DEFER;
|
|
|
|
|
|
|
|
if (rport->port_state != FC_PORTSTATE_ONLINE)
|
|
|
|
return BLKPREP_KILL;
|
|
|
|
|
|
|
|
return BLKPREP_OK;
|
|
|
|
}
|
2009-03-26 11:33:19 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* fc_bsg_rportadd - Create and add the bsg hooks so we can receive requests
|
|
|
|
* @shost: shost that rport is attached to
|
|
|
|
* @rport: rport that the bsg hooks are being attached to
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
fc_bsg_rportadd(struct Scsi_Host *shost, struct fc_rport *rport)
|
|
|
|
{
|
|
|
|
struct device *dev = &rport->dev;
|
|
|
|
struct fc_internal *i = to_fc_internal(shost->transportt);
|
|
|
|
struct request_queue *q;
|
|
|
|
|
|
|
|
rport->rqst_q = NULL;
|
|
|
|
|
|
|
|
if (!i->f->bsg_request)
|
|
|
|
return -ENOTSUPP;
|
|
|
|
|
2017-01-03 05:25:02 -07:00
|
|
|
q = bsg_setup_queue(dev, NULL, fc_bsg_dispatch, i->f->dd_bsg_size);
|
|
|
|
if (IS_ERR(q)) {
|
2016-11-17 02:31:24 -07:00
|
|
|
dev_err(dev, "failed to setup bsg queue\n");
|
2017-01-03 05:25:02 -07:00
|
|
|
return PTR_ERR(q);
|
2009-03-26 11:33:19 -06:00
|
|
|
}
|
2017-01-03 05:25:02 -07:00
|
|
|
__scsi_init_queue(shost, q);
|
2016-11-17 02:31:24 -07:00
|
|
|
blk_queue_prep_rq(q, fc_bsg_rport_prep);
|
|
|
|
blk_queue_rq_timed_out(q, fc_bsg_job_timeout);
|
|
|
|
blk_queue_rq_timeout(q, BLK_DEFAULT_SG_TIMEOUT);
|
2009-03-26 11:33:19 -06:00
|
|
|
rport->rqst_q = q;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fc_bsg_remove - Deletes the bsg hooks on fchosts/rports
|
|
|
|
* @q: the request_queue that is to be torn down.
|
2010-08-31 20:27:31 -06:00
|
|
|
*
|
|
|
|
* Notes:
|
|
|
|
* Before unregistering the queue empty any requests that are blocked
|
|
|
|
*
|
|
|
|
*
|
2009-03-26 11:33:19 -06:00
|
|
|
*/
|
|
|
|
static void
|
|
|
|
fc_bsg_remove(struct request_queue *q)
|
|
|
|
{
|
|
|
|
if (q) {
|
|
|
|
bsg_unregister_queue(q);
|
|
|
|
blk_cleanup_queue(q);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-24 17:04:44 -06:00
|
|
|
/* Original Author: Martin Hicks */
|
|
|
|
MODULE_AUTHOR("James Smart");
|
2005-04-16 16:20:36 -06:00
|
|
|
MODULE_DESCRIPTION("FC Transport Attributes");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
module_init(fc_transport_init);
|
|
|
|
module_exit(fc_transport_exit);
|