Linux SCSI subsystem development
 help / color / mirror / Atom feed
* Re: [PATCH] target: Fix tcm_mod_builder.py default EXTRA_CFLAGS
From: Christoph Hellwig @ 2011-01-18 21:36 UTC (permalink / raw)
  To: Nicholas A. Bellinger; +Cc: linux-scsi, Christoph Hellwig
In-Reply-To: <1295386222-12869-1-git-send-email-nab@linux-iscsi.org>

On Tue, Jan 18, 2011 at 01:30:22PM -0800, Nicholas A. Bellinger wrote:
> +	buf = "EXTRA_CFLAGS += -I$(srctree)/include/ -I$(srctree)/drivers/target/" + fabric_mod_name + "\n\n"

-I$(srctree)/include/ is never needed, that's added automatically.
Similarly adding the directory of the driver itself (assuming that's
what the second one is supposed to be) is not needed either.


^ permalink raw reply

* Re: [PATCH] target: remove EXTRA_CFLAGS
From: Nicholas A. Bellinger @ 2011-01-18 21:31 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-scsi
In-Reply-To: <20110118212043.GA12597@lst.de>

On Tue, 2011-01-18 at 22:20 +0100, Christoph Hellwig wrote:
> On Tue, Jan 18, 2011 at 12:59:16PM -0800, Nicholas A. Bellinger wrote:
> > On Tue, 2011-01-18 at 21:24 +0100, Christoph Hellwig wrote:
> > > Add the current directory is superflous in general, and no includes in
> > > drivers/scsi are needed either.
> > > 
> > > Signed-off-by: Christoph Hellwig <hch@lst.de>
> > > 
> > 
> > Committed as c524eda into lio-core-2.6.git and picked into
> > scsi-post-merge-2.6.git/for-jejb.
> 
> tcm_mod_builder.py should get a similar treatment, but I'm not python
> savy enough to not fuck that up.
> --

;)

Committed as 8ff3e08 into lio-core-2.6.git and picked into
scsi-post-merge-2.6.git/for-jejb.

Thanks!

--nab


^ permalink raw reply

* [PATCH] target: Fix tcm_mod_builder.py default EXTRA_CFLAGS
From: Nicholas A. Bellinger @ 2011-01-18 21:30 UTC (permalink / raw)
  To: linux-scsi, Christoph Hellwig; +Cc: Nicholas Bellinger

From: Nicholas Bellinger <nab@linux-iscsi.org>

This patch removes the unnecessary default EXTRA_CFLAGS include paths
for newly generated fabric modules, which now only contains:

	include/
	drivers/target/$NEW_FABRIC_MOD

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
---
 Documentation/target/tcm_mod_builder.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Documentation/target/tcm_mod_builder.py b/Documentation/target/tcm_mod_builder.py
index bb0038c..cf857c0 100755
--- a/Documentation/target/tcm_mod_builder.py
+++ b/Documentation/target/tcm_mod_builder.py
@@ -980,7 +980,7 @@ def tcm_mod_build_kbuild(fabric_mod_dir_var, fabric_mod_name):
 	if not p:
 		tcm_mod_err("Unable to open file: " + f)
 
-	buf = "EXTRA_CFLAGS += -I$(srctree)/drivers/target/ -I$(srctree)/include/ -I$(srctree)/drivers/scsi/ -I$(srctree)/include/scsi/ -I$(srctree)/drivers/target/" + fabric_mod_name + "\n\n"
+	buf = "EXTRA_CFLAGS += -I$(srctree)/include/ -I$(srctree)/drivers/target/" + fabric_mod_name + "\n\n"
 	buf += fabric_mod_name + "-objs			:= " + fabric_mod_name + "_fabric.o \\\n"
 	buf += "					   " + fabric_mod_name + "_configfs.o\n"
 	buf += "obj-$(CONFIG_" + fabric_mod_name.upper() + ")		+= " + fabric_mod_name + ".o\n"
-- 
1.7.3.5


^ permalink raw reply related

* Re: [PATCH] target: remove EXTRA_CFLAGS
From: Christoph Hellwig @ 2011-01-18 21:20 UTC (permalink / raw)
  To: Nicholas A. Bellinger; +Cc: linux-scsi
In-Reply-To: <1295384356.22813.442.camel@haakon2.linux-iscsi.org>

On Tue, Jan 18, 2011 at 12:59:16PM -0800, Nicholas A. Bellinger wrote:
> On Tue, 2011-01-18 at 21:24 +0100, Christoph Hellwig wrote:
> > Add the current directory is superflous in general, and no includes in
> > drivers/scsi are needed either.
> > 
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> > 
> 
> Committed as c524eda into lio-core-2.6.git and picked into
> scsi-post-merge-2.6.git/for-jejb.

tcm_mod_builder.py should get a similar treatment, but I'm not python
savy enough to not fuck that up.

^ permalink raw reply

* Re: [PATCH] target_core_mib.h move
From: Nicholas A. Bellinger @ 2011-01-18 21:02 UTC (permalink / raw)
  To: Fubo Chen; +Cc: Christoph Hellwig, linux-scsi
In-Reply-To: <1295381563.22813.429.camel@haakon2.linux-iscsi.org>

On Tue, 2011-01-18 at 12:12 -0800, Nicholas A. Bellinger wrote:
> On Tue, 2011-01-18 at 17:58 +0100, Fubo Chen wrote:
> > On Mon, Jan 17, 2011 at 9:51 PM, Christoph Hellwig <hch@infradead.org> wrote:
> > > On Mon, Jan 17, 2011 at 09:00:02PM +0100, Fubo Chen wrote:
> > >> target_core_mib.h move from drivers/target to include/target.
> > >> Otherwise my driver not build.
> > >>
> > >> Signed-off-by: Fubo Chen <fubo.chen@gmail.com>
> > >
> > > Why does the driver need to poke into the target MIB code directly?
> > 
> > I should ask you why.
> > 
> > > Can you post the driver?
> > 
> > Compiler says:
> > 
> > $ make M=drivers/target modules
> >   CC [M]  drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.o
> > In file included from drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.c:15:0:
> > include/target/target_core_base.h:11:29: fatal error:
> > target_core_mib.h: No such file or directory
> > compilation terminated.
> > make[2]: *** [drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.o] Error 1
> > make[1]: *** [drivers/target/tcm_mvsas_tgt] Error 2
> > make: *** [_module_drivers/target] Error 2
> > 
> > for this driver:
> > 
> > ---
> >  drivers/target/Kbuild                              |    1 +
> >  drivers/target/Kconfig                             |    2 +
> >  drivers/target/tcm_mvsas_tgt/Kbuild                |    3 +
> >  drivers/target/tcm_mvsas_tgt/Kconfig               |    6 +
> >  drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_base.h  |   31 ++
> >  .../target/tcm_mvsas_tgt/tcm_mvsas_tgt_configfs.c  |  298 ++++++++++++++++++++
> >  .../target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.c    |  272 ++++++++++++++++++
> >  .../target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.h    |   39 +++
> >  8 files changed, 652 insertions(+), 0 deletions(-)
> >  create mode 100644 drivers/target/Kbuild
> >  create mode 100644 drivers/target/tcm_mvsas_tgt/Kbuild
> >  create mode 100644 drivers/target/tcm_mvsas_tgt/Kconfig
> >  create mode 100644 drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_base.h
> >  create mode 100644 drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_configfs.c
> >  create mode 100644 drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.c
> >  create mode 100644 drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.h
> > 
> > diff --git a/drivers/target/Kbuild b/drivers/target/Kbuild
> > new file mode 100644
> > index 0000000..a997c81
> > --- /dev/null
> > +++ b/drivers/target/Kbuild
> > @@ -0,0 +1 @@
> > +obj-$(CONFIG_TCM_MVSAS_TGT)	+= tcm_mvsas_tgt/
> > diff --git a/drivers/target/Kconfig b/drivers/target/Kconfig
> > index 2fac3be..85dcc60 100644
> > --- a/drivers/target/Kconfig
> > +++ b/drivers/target/Kconfig
> > @@ -29,4 +29,6 @@ config TCM_PSCSI
> >  	Say Y here to enable the TCM/pSCSI subsystem plugin for non-buffered
> >  	passthrough access to Linux/SCSI device
> > 
> > +source drivers/target/mvsas_tgt/Kconfig
> > +
> >  endif
> > diff --git a/drivers/target/tcm_mvsas_tgt/Kbuild
> > b/drivers/target/tcm_mvsas_tgt/Kbuild
> > new file mode 100644
> > index 0000000..1c179d7
> > --- /dev/null
> > +++ b/drivers/target/tcm_mvsas_tgt/Kbuild
> > @@ -0,0 +1,3 @@
> > +tcm_mvsas_tgt-objs			:= tcm_mvsas_tgt_fabric.o \
> > +					   tcm_mvsas_tgt_configfs.o
> > +obj-$(CONFIG_TCM_MVSAS_TGT)		+= tcm_mvsas_tgt.o
> 
> I think this fabric module was generated with an older version of
> Documentation/target/tcm_mod_builder.py, right..?
> 
> After doing a quick 'tcm_mod_builder.py -m tcm_mvsas_tgt -p SAS' with
> mainline code, the newly generated tcm_mvsas_tgt.ko builds as expected..
> 
> [nab@hera lio-core-2.6.git]$ make
> drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt.ko
>   CHK     include/linux/version.h
>   CHK     include/generated/utsrelease.h
>   CALL    scripts/checksyscalls.sh
>   CC [M]  drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.o
>   CC [M]  drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_configfs.o
>   LD [M]  drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt.o
>   MODPOST 2 modules
>   CC      drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt.mod.o
>   LD [M]  drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt.ko
> 
> The bit missing from the top of your Kbuild is:
> 
> EXTRA_CFLAGS += -I$(srctree)/drivers/target/ -I$(srctree)/include/ -I$(srctree)/drivers/scsi/ -I$(srctree)/include/scsi/ -I$(srctree)/drivers/target/tcm_mvsas_tgt
> 
> FYI, depending upon the age of the tcm_mod_builder.py in question , you
> may want to consider re-generating the fabric module skeleton with the
> latest code.
> 

Hi again Fubo,

If you want to re-generate your driver, please make sure to grab the
patch for tcm_mod_builder.py merged into lio-core-2.6.git that
uses /Makefile instead of /Kbuild filenames here:

target: Convert tcm_mod_builder.py from Kbuild -> Makefile
http://git.kernel.org/?p=linux/kernel/git/nab/lio-core-2.6.git;a=commitdiff;h=3103722a1cf759d475b9ecd9cdb0df523dbf09ab

Thanks!

--nab



^ permalink raw reply

* Re: [PATCH] target: remove EXTRA_CFLAGS
From: Nicholas A. Bellinger @ 2011-01-18 20:59 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-scsi
In-Reply-To: <20110118202458.GB10884@lst.de>

On Tue, 2011-01-18 at 21:24 +0100, Christoph Hellwig wrote:
> Add the current directory is superflous in general, and no includes in
> drivers/scsi are needed either.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> 

Committed as c524eda into lio-core-2.6.git and picked into
scsi-post-merge-2.6.git/for-jejb.

Thanks!

--nab


^ permalink raw reply

* Re: [PATCH] target: do not include target_core_mib.h under include/target
From: Nicholas A. Bellinger @ 2011-01-18 20:58 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-scsi
In-Reply-To: <20110118202434.GA10884@lst.de>

On Tue, 2011-01-18 at 21:24 +0100, Christoph Hellwig wrote:
> Headers under include/ should not include headers that require a specific
> include path.  Fix this by moving the defintion of scsi_port_stats to
> target_core_base.h, and including target_core_mib.h directly where needed.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Thanks Christoph..  Committed as 0080d7d into lio-core-2.6.git and
picked into scsi-post-merge-2.6.git/for-jejb.

--nab



^ permalink raw reply

* [PATCH] target: Convert tcm_mod_builder.py from Kbuild -> Makefile
From: Nicholas A. Bellinger @ 2011-01-18 20:47 UTC (permalink / raw)
  To: linux-scsi; +Cc: James Bottomley, Nicholas Bellinger

From: Nicholas Bellinger <nab@linux-iscsi.org>

This patch converts the tcm_mod_builder.py generation script to
create a new drivers/target/$TCM_FABRIC_MOD/Makefile and update
drivers/target/Makefile, instead of creating+updating a 'Kbuild'
filename.

Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
---
 Documentation/target/tcm_mod_builder.py |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Documentation/target/tcm_mod_builder.py b/Documentation/target/tcm_mod_builder.py
index dbeb8a0..bb0038c 100755
--- a/Documentation/target/tcm_mod_builder.py
+++ b/Documentation/target/tcm_mod_builder.py
@@ -973,7 +973,7 @@ def tcm_mod_dump_fabric_ops(proto_ident, fabric_mod_dir_var, fabric_mod_name):
 def tcm_mod_build_kbuild(fabric_mod_dir_var, fabric_mod_name):
 
 	buf = ""
-	f = fabric_mod_dir_var + "/Kbuild"
+	f = fabric_mod_dir_var + "/Makefile"
 	print "Writing file: " + f
 
 	p = open(f, 'w')
@@ -1018,7 +1018,7 @@ def tcm_mod_build_kconfig(fabric_mod_dir_var, fabric_mod_name):
 
 def tcm_mod_add_kbuild(tcm_dir, fabric_mod_name):
 	buf = "obj-$(CONFIG_" + fabric_mod_name.upper() + ")	+= " + fabric_mod_name.lower() + "/\n"
-	kbuild = tcm_dir + "/drivers/target/Kbuild"
+	kbuild = tcm_dir + "/drivers/target/Makefile"
 
 	f = open(kbuild, 'a')
 	f.write(buf)
@@ -1064,7 +1064,7 @@ def main(modname, proto_ident):
 	tcm_mod_build_kbuild(fabric_mod_dir, fabric_mod_name)
 	tcm_mod_build_kconfig(fabric_mod_dir, fabric_mod_name)
 
-	input = raw_input("Would you like to add " + fabric_mod_name + "to drivers/target/Kbuild..? [yes,no]: ")
+	input = raw_input("Would you like to add " + fabric_mod_name + "to drivers/target/Makefile..? [yes,no]: ")
 	if input == "yes" or input == "y":
 		tcm_mod_add_kbuild(tcm_dir, fabric_mod_name)
 
-- 
1.7.3.5


^ permalink raw reply related

* scsi_sysfs.c: make local symbols static
From: H Hartley Sweeten @ 2011-01-18 20:40 UTC (permalink / raw)
  To: Linux Kernel; +Cc: linux-scsi, James.Bottomley

The symbols dev_attr_hstate and scsi_shost_attr_group are only used
locally in this file and should be declared static.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: James E.J. Bottomley <James.Bottomley@suse.de>

---

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 490ce21..2e35979 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -197,7 +197,7 @@ show_shost_state(struct device *dev, struct device_attribute *attr, char *buf)
 }
 
 /* DEVICE_ATTR(state) clashes with dev_attr_state for sdev */
-struct device_attribute dev_attr_hstate =
+static struct device_attribute dev_attr_hstate =
 	__ATTR(state, S_IRUGO | S_IWUSR, show_shost_state, store_shost_state);
 
 static ssize_t
@@ -275,7 +275,7 @@ static struct attribute *scsi_sysfs_shost_attrs[] = {
 	NULL
 };
 
-struct attribute_group scsi_shost_attr_group = {
+static struct attribute_group scsi_shost_attr_group = {
 	.attrs =	scsi_sysfs_shost_attrs,
 };
 

^ permalink raw reply related

* scsi_scan.c: quiet sparse noise
From: H Hartley Sweeten @ 2011-01-18 20:28 UTC (permalink / raw)
  To: Linux Kernel; +Cc: linux-scsi, James.Bottomley

Include header to quiet sparse noise about scsi_complete_async_scans
not being declared.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: James E.J. Bottomley <James.Bottomley@suse.de>

---

diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 087821f..f1ef02b 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -43,6 +43,7 @@
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_transport.h>
 #include <scsi/scsi_eh.h>
+#include <scsi/scsi_scan.h>
 
 #include "scsi_priv.h"
 #include "scsi_logging.h"

^ permalink raw reply related

* [PATCH] target: remove EXTRA_CFLAGS
From: Christoph Hellwig @ 2011-01-18 20:24 UTC (permalink / raw)
  To: nab; +Cc: linux-scsi
In-Reply-To: <20110118202434.GA10884@lst.de>

Add the current directory is superflous in general, and no includes in
drivers/scsi are needed either.

Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: linux-2.6/drivers/target/Makefile
===================================================================
--- linux-2.6.orig/drivers/target/Makefile	2011-01-18 21:13:15.835261618 +0100
+++ linux-2.6/drivers/target/Makefile	2011-01-18 21:14:31.908284597 +0100
@@ -1,4 +1,3 @@
-EXTRA_CFLAGS += -I$(srctree)/drivers/target/ -I$(srctree)/drivers/scsi/
 
 target_core_mod-y		:= target_core_configfs.o \
 				   target_core_device.o \

^ permalink raw reply

* [PATCH] target: do not include target_core_mib.h under include/target
From: Christoph Hellwig @ 2011-01-18 20:24 UTC (permalink / raw)
  To: nab; +Cc: linux-scsi

Headers under include/ should not include headers that require a specific
include path.  Fix this by moving the defintion of scsi_port_stats to
target_core_base.h, and including target_core_mib.h directly where needed.

Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: linux-2.6/drivers/target/target_core_configfs.c
===================================================================
--- linux-2.6.orig/drivers/target/target_core_configfs.c	2011-01-18 21:16:49.361253237 +0100
+++ linux-2.6/drivers/target/target_core_configfs.c	2011-01-18 21:17:03.393006207 +0100
@@ -51,6 +51,7 @@
 #include "target_core_hba.h"
 #include "target_core_pr.h"
 #include "target_core_rd.h"
+#include "target_core_mib.h"
 
 static struct list_head g_tf_list;
 static struct mutex g_tf_lock;
Index: linux-2.6/drivers/target/target_core_hba.c
===================================================================
--- linux-2.6.orig/drivers/target/target_core_hba.c	2011-01-18 21:17:15.067253727 +0100
+++ linux-2.6/drivers/target/target_core_hba.c	2011-01-18 21:17:26.881255543 +0100
@@ -43,6 +43,7 @@
 #include <target/target_core_transport.h>
 
 #include "target_core_hba.h"
+#include "target_core_mib.h"
 
 static LIST_HEAD(subsystem_list);
 static DEFINE_MUTEX(subsystem_mutex);
Index: linux-2.6/drivers/target/target_core_mib.h
===================================================================
--- linux-2.6.orig/drivers/target/target_core_mib.h	2011-01-18 21:15:59.708253238 +0100
+++ linux-2.6/drivers/target/target_core_mib.h	2011-01-18 21:16:13.016005995 +0100
@@ -13,13 +13,6 @@ struct scsi_index_table {
 	u32 		scsi_mib_index[SCSI_INDEX_TYPE_MAX];
 } ____cacheline_aligned;
 
-/* SCSI Port stats */
-struct scsi_port_stats {
-	u64	cmd_pdus;
-	u64	tx_data_octets;
-	u64	rx_data_octets;
-} ____cacheline_aligned;
-
 extern int init_scsi_target_mib(void);
 extern void remove_scsi_target_mib(void);
 extern void init_scsi_index_table(void);
Index: linux-2.6/drivers/target/target_core_tpg.c
===================================================================
--- linux-2.6.orig/drivers/target/target_core_tpg.c	2011-01-18 21:17:38.542004530 +0100
+++ linux-2.6/drivers/target/target_core_tpg.c	2011-01-18 21:17:49.480291791 +0100
@@ -45,6 +45,7 @@
 #include <target/target_core_fabric_ops.h>
 
 #include "target_core_hba.h"
+#include "target_core_mib.h"
 
 /*	core_clear_initiator_node_from_tpg():
  *
Index: linux-2.6/drivers/target/target_core_transport.c
===================================================================
--- linux-2.6.orig/drivers/target/target_core_transport.c	2011-01-18 21:18:00.593253587 +0100
+++ linux-2.6/drivers/target/target_core_transport.c	2011-01-18 21:18:08.858255404 +0100
@@ -58,6 +58,7 @@
 #include "target_core_pr.h"
 #include "target_core_scdb.h"
 #include "target_core_ua.h"
+#include "target_core_mib.h"
 
 /* #define DEBUG_CDB_HANDLER */
 #ifdef DEBUG_CDB_HANDLER
Index: linux-2.6/include/target/target_core_base.h
===================================================================
--- linux-2.6.orig/include/target/target_core_base.h	2011-01-18 21:14:57.945011025 +0100
+++ linux-2.6/include/target/target_core_base.h	2011-01-18 21:20:44.166015774 +0100
@@ -8,7 +8,6 @@
 #include <scsi/scsi_cmnd.h>
 #include <net/sock.h>
 #include <net/tcp.h>
-#include "target_core_mib.h"
 
 #define TARGET_CORE_MOD_VERSION		"v4.0.0-rc6"
 #define SHUTDOWN_SIGS	(sigmask(SIGKILL)|sigmask(SIGINT)|sigmask(SIGABRT))
@@ -175,6 +174,13 @@ struct se_obj {
 	atomic_t obj_access_count;
 } ____cacheline_aligned;
 
+/* SCSI Port stats */
+struct scsi_port_stats {
+	u64	cmd_pdus;
+	u64	tx_data_octets;
+	u64	rx_data_octets;
+} ____cacheline_aligned;
+
 /*
  * Used by TCM Core internally to signal if ALUA emulation is enabled or
  * disabled, or running in with TCM/pSCSI passthrough mode

^ permalink raw reply

* Re: [PATCH] target_core_mib.h move
From: Christoph Hellwig @ 2011-01-18 20:15 UTC (permalink / raw)
  To: Nicholas A. Bellinger; +Cc: Fubo Chen, Christoph Hellwig, linux-scsi
In-Reply-To: <1295381563.22813.429.camel@haakon2.linux-iscsi.org>

On Tue, Jan 18, 2011 at 12:12:43PM -0800, Nicholas A. Bellinger wrote:
> EXTRA_CFLAGS += -I$(srctree)/drivers/target/ -I$(srctree)/include/ -I$(srctree)/drivers/scsi/ -I$(srctree)/include/scsi/ -I$(srctree)/drivers/target/tcm_mvsas_tgt
> 
> FYI, depending upon the age of the tcm_mod_builder.py in question , you
> may want to consider re-generating the fabric module skeleton with the
> latest code.

This shouldn't be nessecary.  Except for special cases driver should
never need special include paths.  I still don't see why the mib header
should be needed by drivers, but if it is it needs to move under
include/. 


^ permalink raw reply

* Re: [PATCH] target_core_mib.h move
From: Nicholas A. Bellinger @ 2011-01-18 20:12 UTC (permalink / raw)
  To: Fubo Chen; +Cc: Christoph Hellwig, linux-scsi
In-Reply-To: <AANLkTinNiohS+9WDcCP4P=0beRRE53x4iFC9u7iXBOy2@mail.gmail.com>

On Tue, 2011-01-18 at 17:58 +0100, Fubo Chen wrote:
> On Mon, Jan 17, 2011 at 9:51 PM, Christoph Hellwig <hch@infradead.org> wrote:
> > On Mon, Jan 17, 2011 at 09:00:02PM +0100, Fubo Chen wrote:
> >> target_core_mib.h move from drivers/target to include/target.
> >> Otherwise my driver not build.
> >>
> >> Signed-off-by: Fubo Chen <fubo.chen@gmail.com>
> >
> > Why does the driver need to poke into the target MIB code directly?
> 
> I should ask you why.
> 
> > Can you post the driver?
> 
> Compiler says:
> 
> $ make M=drivers/target modules
>   CC [M]  drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.o
> In file included from drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.c:15:0:
> include/target/target_core_base.h:11:29: fatal error:
> target_core_mib.h: No such file or directory
> compilation terminated.
> make[2]: *** [drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.o] Error 1
> make[1]: *** [drivers/target/tcm_mvsas_tgt] Error 2
> make: *** [_module_drivers/target] Error 2
> 
> for this driver:
> 
> ---
>  drivers/target/Kbuild                              |    1 +
>  drivers/target/Kconfig                             |    2 +
>  drivers/target/tcm_mvsas_tgt/Kbuild                |    3 +
>  drivers/target/tcm_mvsas_tgt/Kconfig               |    6 +
>  drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_base.h  |   31 ++
>  .../target/tcm_mvsas_tgt/tcm_mvsas_tgt_configfs.c  |  298 ++++++++++++++++++++
>  .../target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.c    |  272 ++++++++++++++++++
>  .../target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.h    |   39 +++
>  8 files changed, 652 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/target/Kbuild
>  create mode 100644 drivers/target/tcm_mvsas_tgt/Kbuild
>  create mode 100644 drivers/target/tcm_mvsas_tgt/Kconfig
>  create mode 100644 drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_base.h
>  create mode 100644 drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_configfs.c
>  create mode 100644 drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.c
>  create mode 100644 drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.h
> 
> diff --git a/drivers/target/Kbuild b/drivers/target/Kbuild
> new file mode 100644
> index 0000000..a997c81
> --- /dev/null
> +++ b/drivers/target/Kbuild
> @@ -0,0 +1 @@
> +obj-$(CONFIG_TCM_MVSAS_TGT)	+= tcm_mvsas_tgt/
> diff --git a/drivers/target/Kconfig b/drivers/target/Kconfig
> index 2fac3be..85dcc60 100644
> --- a/drivers/target/Kconfig
> +++ b/drivers/target/Kconfig
> @@ -29,4 +29,6 @@ config TCM_PSCSI
>  	Say Y here to enable the TCM/pSCSI subsystem plugin for non-buffered
>  	passthrough access to Linux/SCSI device
> 
> +source drivers/target/mvsas_tgt/Kconfig
> +
>  endif
> diff --git a/drivers/target/tcm_mvsas_tgt/Kbuild
> b/drivers/target/tcm_mvsas_tgt/Kbuild
> new file mode 100644
> index 0000000..1c179d7
> --- /dev/null
> +++ b/drivers/target/tcm_mvsas_tgt/Kbuild
> @@ -0,0 +1,3 @@
> +tcm_mvsas_tgt-objs			:= tcm_mvsas_tgt_fabric.o \
> +					   tcm_mvsas_tgt_configfs.o
> +obj-$(CONFIG_TCM_MVSAS_TGT)		+= tcm_mvsas_tgt.o

I think this fabric module was generated with an older version of
Documentation/target/tcm_mod_builder.py, right..?

After doing a quick 'tcm_mod_builder.py -m tcm_mvsas_tgt -p SAS' with
mainline code, the newly generated tcm_mvsas_tgt.ko builds as expected..

[nab@hera lio-core-2.6.git]$ make
drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt.ko
  CHK     include/linux/version.h
  CHK     include/generated/utsrelease.h
  CALL    scripts/checksyscalls.sh
  CC [M]  drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.o
  CC [M]  drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_configfs.o
  LD [M]  drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt.o
  MODPOST 2 modules
  CC      drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt.mod.o
  LD [M]  drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt.ko

The bit missing from the top of your Kbuild is:

EXTRA_CFLAGS += -I$(srctree)/drivers/target/ -I$(srctree)/include/ -I$(srctree)/drivers/scsi/ -I$(srctree)/include/scsi/ -I$(srctree)/drivers/target/tcm_mvsas_tgt

FYI, depending upon the age of the tcm_mod_builder.py in question , you
may want to consider re-generating the fabric module skeleton with the
latest code.

Thanks!

--nab



^ permalink raw reply

* RE: [PATCH 0/10] mpt2sas: Description Patch
From: Desai, Kashyap @ 2011-01-18 18:29 UTC (permalink / raw)
  To: James.Bottomley@HansenPartnership.com
  Cc: Moore, Eric, Prakash, Sathya, linux-scsi@vger.kernel.org
In-Reply-To: <20110104060032.GA5751@lsi.com>

James,

Any feedback on this patch set. ? 

Thanks, Kashyap

> -----Original Message-----
> From: linux-scsi-owner@vger.kernel.org [mailto:linux-scsi-
> owner@vger.kernel.org] On Behalf Of Kashyap, Desai
> Sent: Tuesday, January 04, 2011 11:31 AM
> To: linux-scsi@vger.kernel.org
> Cc: James.Bottomley@HansenPartnership.com; Moore, Eric; Prakash, Sathya
> Subject: [PATCH 0/10] mpt2sas: Description Patch
> 
> 
> MPT2SAS driver changes.
> These patches are taken from 2.6.37-rc5.
> Please consider this patch set for next kernel release.
> 
> [PATCH 01/10] mpt2sas: Device removal handshake even though the
> PHYSTATUS_VACANT bit is set in the PhyStatus
> [PATCH 02/10] mpt2sas: Internal device reset complete event is not
> supported for older firmware prior to MPI Rev K
> [PATCH 03/10] mpt2sas: Correct resizing calculation for max_queue_depth
> [PATCH 04/10] mpt2sas: Revision P MPI Header Update
> [PATCH 05/10] mpt2sas: Add support for Customer specific branding
> messages
> [PATCH 06/10] mpt2sas: Fix the race between broadcast asyn event and
> scsi
> command completion.
> [PATCH 07/10] mpt2sas: Prevent access to freed memory from port enable
> process
> [PATCH 08/10] mpt2sas: Basic Code Cleanup in mpt2sas_base
> [PATCH 09/10] mpt2sas: Call the _scsih_ir_shutdown prior to reporting
> the
> volumes missing from the OS
> [PATCH 10/10] mpt2sas: Bump version 08.100.00.00
> 
> Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
> ---
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi"
> in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH] target_core_mib.h move
From: Fubo Chen @ 2011-01-18 16:58 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-scsi, Nicholas A. Bellinger
In-Reply-To: <20110117205130.GA22532@infradead.org>

On Mon, Jan 17, 2011 at 9:51 PM, Christoph Hellwig <hch@infradead.org> wrote:
> On Mon, Jan 17, 2011 at 09:00:02PM +0100, Fubo Chen wrote:
>> target_core_mib.h move from drivers/target to include/target.
>> Otherwise my driver not build.
>>
>> Signed-off-by: Fubo Chen <fubo.chen@gmail.com>
>
> Why does the driver need to poke into the target MIB code directly?

I should ask you why.

> Can you post the driver?

Compiler says:

$ make M=drivers/target modules
  CC [M]  drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.o
In file included from drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.c:15:0:
include/target/target_core_base.h:11:29: fatal error:
target_core_mib.h: No such file or directory
compilation terminated.
make[2]: *** [drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.o] Error 1
make[1]: *** [drivers/target/tcm_mvsas_tgt] Error 2
make: *** [_module_drivers/target] Error 2

for this driver:

---
 drivers/target/Kbuild                              |    1 +
 drivers/target/Kconfig                             |    2 +
 drivers/target/tcm_mvsas_tgt/Kbuild                |    3 +
 drivers/target/tcm_mvsas_tgt/Kconfig               |    6 +
 drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_base.h  |   31 ++
 .../target/tcm_mvsas_tgt/tcm_mvsas_tgt_configfs.c  |  298 ++++++++++++++++++++
 .../target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.c    |  272 ++++++++++++++++++
 .../target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.h    |   39 +++
 8 files changed, 652 insertions(+), 0 deletions(-)
 create mode 100644 drivers/target/Kbuild
 create mode 100644 drivers/target/tcm_mvsas_tgt/Kbuild
 create mode 100644 drivers/target/tcm_mvsas_tgt/Kconfig
 create mode 100644 drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_base.h
 create mode 100644 drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_configfs.c
 create mode 100644 drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.c
 create mode 100644 drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.h

diff --git a/drivers/target/Kbuild b/drivers/target/Kbuild
new file mode 100644
index 0000000..a997c81
--- /dev/null
+++ b/drivers/target/Kbuild
@@ -0,0 +1 @@
+obj-$(CONFIG_TCM_MVSAS_TGT)	+= tcm_mvsas_tgt/
diff --git a/drivers/target/Kconfig b/drivers/target/Kconfig
index 2fac3be..85dcc60 100644
--- a/drivers/target/Kconfig
+++ b/drivers/target/Kconfig
@@ -29,4 +29,6 @@ config TCM_PSCSI
 	Say Y here to enable the TCM/pSCSI subsystem plugin for non-buffered
 	passthrough access to Linux/SCSI device

+source drivers/target/mvsas_tgt/Kconfig
+
 endif
diff --git a/drivers/target/tcm_mvsas_tgt/Kbuild
b/drivers/target/tcm_mvsas_tgt/Kbuild
new file mode 100644
index 0000000..1c179d7
--- /dev/null
+++ b/drivers/target/tcm_mvsas_tgt/Kbuild
@@ -0,0 +1,3 @@
+tcm_mvsas_tgt-objs			:= tcm_mvsas_tgt_fabric.o \
+					   tcm_mvsas_tgt_configfs.o
+obj-$(CONFIG_TCM_MVSAS_TGT)		+= tcm_mvsas_tgt.o
diff --git a/drivers/target/tcm_mvsas_tgt/Kconfig
b/drivers/target/tcm_mvsas_tgt/Kconfig
new file mode 100644
index 0000000..4e505fb
--- /dev/null
+++ b/drivers/target/tcm_mvsas_tgt/Kconfig
@@ -0,0 +1,6 @@
+config TCM_MVSAS_TGT
+	tristate "TCM_MVSAS_TGT fabric module"
+	depends on TARGET_CORE && CONFIGFS_FS
+	default n
+	---help---
+	Say Y here to enable the TCM_MVSAS_TGT fabric module
diff --git a/drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_base.h
b/drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_base.h
new file mode 100644
index 0000000..44d1a03
--- /dev/null
+++ b/drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_base.h
@@ -0,0 +1,31 @@
+#define TCM_MVSAS_TGT_VERSION  "v0.1"
+#define TCM_MVSAS_TGT_NAMELEN 32
+
+struct tcm_mvsas_tgt_nacl {
+	/* Binary World Wide unique Port Name for SAS Initiator port */
+	u64 iport_wwpn;
+	/* ASCII formatted WWPN for Sas Initiator port */
+	char iport_name[TCM_MVSAS_TGT_NAMELEN];
+	/* Returned by tcm_mvsas_tgt_make_nodeacl() */
+	struct se_node_acl se_node_acl;
+};
+
+struct tcm_mvsas_tgt_tpg {
+	/* SAS port target portal group tag for TCM */
+	u16 tport_tpgt;
+	/* Pointer back to tcm_mvsas_tgt_tport */
+	struct tcm_mvsas_tgt_tport *tport;
+	/* Returned by tcm_mvsas_tgt_make_tpg() */
+	struct se_portal_group se_tpg;
+};
+
+struct tcm_mvsas_tgt_tport {
+	/* SCSI protocol the tport is providing */
+	u8 tport_proto_id;
+	/* Binary World Wide unique Port Name for SAS Target port */
+	u64 tport_wwpn;
+	/* ASCII formatted WWPN for SAS Target port */
+	char tport_name[TCM_MVSAS_TGT_NAMELEN];
+	/* Returned by tcm_mvsas_tgt_make_tport() */
+	struct se_wwn tport_wwn;
+};
diff --git a/drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_configfs.c
b/drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_configfs.c
new file mode 100644
index 0000000..7a4e938
--- /dev/null
+++ b/drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_configfs.c
@@ -0,0 +1,298 @@
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/version.h>
+#include <generated/utsrelease.h>
+#include <linux/utsname.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/kthread.h>
+#include <linux/types.h>
+#include <linux/string.h>
+#include <linux/configfs.h>
+#include <linux/ctype.h>
+#include <asm/unaligned.h>
+
+#include <target/target_core_base.h>
+#include <target/target_core_transport.h>
+#include <target/target_core_fabric_ops.h>
+#include <target/target_core_fabric_configfs.h>
+#include <target/target_core_fabric_lib.h>
+#include <target/target_core_device.h>
+#include <target/target_core_tpg.h>
+#include <target/target_core_configfs.h>
+#include <target/target_core_base.h>
+#include <target/configfs_macros.h>
+
+#include <tcm_mvsas_tgt_base.h>
+#include <tcm_mvsas_tgt_fabric.h>
+
+/* Local pointer to allocated TCM configfs fabric module */
+struct target_fabric_configfs *tcm_mvsas_tgt_fabric_configfs;
+
+static struct se_node_acl *tcm_mvsas_tgt_make_nodeacl(
+	struct se_portal_group *se_tpg,
+	struct config_group *group,
+	const char *name)
+{
+	struct se_node_acl *se_nacl, *se_nacl_new;
+	struct tcm_mvsas_tgt_nacl *nacl;
+	u64 wwpn = 0;
+	u32 nexus_depth;
+
+	/* tcm_mvsas_tgt_parse_wwn(name, &wwpn, 1) < 0)
+		return ERR_PTR(-EINVAL); */
+	se_nacl_new = tcm_mvsas_tgt_alloc_fabric_acl(se_tpg);
+	if (!(se_nacl_new))
+		return ERR_PTR(-ENOMEM);
+//#warning FIXME: Hardcoded nexus depth in tcm_mvsas_tgt_make_nodeacl()
+	nexus_depth = 1;
+	/*
+	 * se_nacl_new may be released by core_tpg_add_initiator_node_acl()
+	 * when converting a NodeACL from demo mode -> explict
+	 */
+	se_nacl = core_tpg_add_initiator_node_acl(se_tpg, se_nacl_new,
+				name, nexus_depth);
+	if (IS_ERR(se_nacl)) {
+		tcm_mvsas_tgt_release_fabric_acl(se_tpg, se_nacl_new);
+		return se_nacl;
+	}
+	/*
+	 * Locate our struct tcm_mvsas_tgt_nacl and set the FC Nport WWPN
+	 */
+	nacl = container_of(se_nacl, struct tcm_mvsas_tgt_nacl, se_node_acl);
+	nacl->iport_wwpn = wwpn;
+	/* tcm_mvsas_tgt_format_wwn(&nacl->iport_name[0],
TCM_MVSAS_TGT_NAMELEN, wwpn); */
+
+	return se_nacl;
+}
+
+static void tcm_mvsas_tgt_drop_nodeacl(struct se_node_acl *se_acl)
+{
+	struct tcm_mvsas_tgt_nacl *nacl = container_of(se_acl,
+				struct tcm_mvsas_tgt_nacl, se_node_acl);
+	kfree(nacl);
+}
+
+static struct se_portal_group *tcm_mvsas_tgt_make_tpg(
+	struct se_wwn *wwn,
+	struct config_group *group,
+	const char *name)
+{
+	struct tcm_mvsas_tgt_tport*tport = container_of(wwn,
+			struct tcm_mvsas_tgt_tport, tport_wwn);
+
+	struct tcm_mvsas_tgt_tpg *tpg;
+	unsigned long tpgt;
+	int ret;
+
+	if (strstr(name, "tpgt_") != name)
+		return ERR_PTR(-EINVAL);
+	if (strict_strtoul(name + 5, 10, &tpgt) || tpgt > UINT_MAX)
+		return ERR_PTR(-EINVAL);
+
+	tpg = kzalloc(sizeof(struct tcm_mvsas_tgt_tpg), GFP_KERNEL);
+	if (!(tpg)) {
+		printk(KERN_ERR "Unable to allocate struct tcm_mvsas_tgt_tpg");
+		return ERR_PTR(-ENOMEM);
+	}
+	tpg->tport = tport;
+	tpg->tport_tpgt = tpgt;
+
+	ret = core_tpg_register(&tcm_mvsas_tgt_fabric_configfs->tf_ops, wwn,
+				&tpg->se_tpg, (void *)tpg,
+				TRANSPORT_TPG_TYPE_NORMAL);
+	if (ret < 0) {
+		kfree(tpg);
+		return NULL;
+	}
+	return &tpg->se_tpg;
+}
+
+static void tcm_mvsas_tgt_drop_tpg(struct se_portal_group *se_tpg)
+{
+	struct tcm_mvsas_tgt_tpg *tpg = container_of(se_tpg,
+				struct tcm_mvsas_tgt_tpg, se_tpg);
+
+	core_tpg_deregister(se_tpg);
+	kfree(tpg);
+}
+
+static struct se_wwn *tcm_mvsas_tgt_make_tport(
+	struct target_fabric_configfs *tf,
+	struct config_group *group,
+	const char *name)
+{
+	struct tcm_mvsas_tgt_tport *tport;
+	u64 wwpn = 0;
+
+	/* if (tcm_mvsas_tgt_parse_wwn(name, &wwpn, 1) < 0)
+		return ERR_PTR(-EINVAL); */
+
+	tport = kzalloc(sizeof(struct tcm_mvsas_tgt_tport), GFP_KERNEL);
+	if (!(tport)) {
+		printk(KERN_ERR "Unable to allocate struct tcm_mvsas_tgt_tport");
+		return ERR_PTR(-ENOMEM);
+	}
+	tport->tport_wwpn = wwpn;
+	/* tcm_mvsas_tgt_format_wwn(&tport->tport_name[0],
TCM_MVSAS_TGT__NAMELEN, wwpn); */
+
+	return &tport->tport_wwn;
+}
+
+static void tcm_mvsas_tgt_drop_tport(struct se_wwn *wwn)
+{
+	struct tcm_mvsas_tgt_tport *tport = container_of(wwn,
+				struct tcm_mvsas_tgt_tport, tport_wwn);
+	kfree(tport);
+}
+
+static ssize_t tcm_mvsas_tgt_wwn_show_attr_version(
+	struct target_fabric_configfs *tf,
+	char *page)
+{
+	return sprintf(page, "TCM_MVSAS_TGT fabric module %s on %s/%s"
+		"on "UTS_RELEASE"\n", TCM_MVSAS_TGT_VERSION, utsname()->sysname,
+		utsname()->machine);
+}
+
+TF_WWN_ATTR_RO(tcm_mvsas_tgt, version);
+
+static struct configfs_attribute *tcm_mvsas_tgt_wwn_attrs[] = {
+	&tcm_mvsas_tgt_wwn_version.attr,
+	NULL,
+};
+
+static struct target_core_fabric_ops tcm_mvsas_tgt_ops = {
+	.get_fabric_name		= tcm_mvsas_tgt_get_fabric_name,
+	.get_fabric_proto_ident		= tcm_mvsas_tgt_get_fabric_proto_ident,
+	.tpg_get_wwn			= tcm_mvsas_tgt_get_fabric_wwn,
+	.tpg_get_tag			= tcm_mvsas_tgt_get_tag,
+	.tpg_get_default_depth		= tcm_mvsas_tgt_get_default_depth,
+	.tpg_get_pr_transport_id	= tcm_mvsas_tgt_get_pr_transport_id,
+	.tpg_get_pr_transport_id_len	= tcm_mvsas_tgt_get_pr_transport_id_len,
+	.tpg_parse_pr_out_transport_id	= tcm_mvsas_tgt_parse_pr_out_transport_id,
+	.tpg_check_demo_mode		= tcm_mvsas_tgt_check_false,
+	.tpg_check_demo_mode_cache	= tcm_mvsas_tgt_check_true,
+	.tpg_check_demo_mode_write_protect = tcm_mvsas_tgt_check_true,
+	.tpg_check_prod_mode_write_protect = tcm_mvsas_tgt_check_false,
+	.tpg_alloc_fabric_acl		= tcm_mvsas_tgt_alloc_fabric_acl,
+	.tpg_release_fabric_acl		= tcm_mvsas_tgt_release_fabric_acl,
+	.tpg_get_inst_index		= tcm_mvsas_tgt_tpg_get_inst_index,
+	.release_cmd_to_pool		= tcm_mvsas_tgt_release_cmd,
+	.release_cmd_direct		= tcm_mvsas_tgt_release_cmd,
+	.shutdown_session		= tcm_mvsas_tgt_shutdown_session,
+	.close_session			= tcm_mvsas_tgt_close_session,
+	.stop_session			= tcm_mvsas_tgt_stop_session,
+	.fall_back_to_erl0		= tcm_mvsas_tgt_reset_nexus,
+	.sess_logged_in			= tcm_mvsas_tgt_sess_logged_in,
+	.sess_get_index			= tcm_mvsas_tgt_sess_get_index,
+	.sess_get_initiator_sid		= NULL,
+	.write_pending			= tcm_mvsas_tgt_write_pending,
+	.write_pending_status		= tcm_mvsas_tgt_write_pending_status,
+	.set_default_node_attributes	= tcm_mvsas_tgt_set_default_node_attrs,
+	.get_task_tag			= tcm_mvsas_tgt_get_task_tag,
+	.get_cmd_state			= tcm_mvsas_tgt_get_cmd_state,
+	.new_cmd_failure		= tcm_mvsas_tgt_new_cmd_failure,
+	.queue_data_in			= tcm_mvsas_tgt_queue_data_in,
+	.queue_status			= tcm_mvsas_tgt_queue_status,
+	.queue_tm_rsp			= tcm_mvsas_tgt_queue_tm_rsp,
+	.get_fabric_sense_len		= tcm_mvsas_tgt_get_fabric_sense_len,
+	.set_fabric_sense_len		= tcm_mvsas_tgt_set_fabric_sense_len,
+	.is_state_remove		= tcm_mvsas_tgt_is_state_remove,
+	.pack_lun			= tcm_mvsas_tgt_pack_lun,
+	/*
+	 * Setup function pointers for generic logic in target_core_fabric_configfs.c
+	 */
+	.fabric_make_wwn		= tcm_mvsas_tgt_make_tport,
+	.fabric_drop_wwn		= tcm_mvsas_tgt_drop_tport,
+	.fabric_make_tpg		= tcm_mvsas_tgt_make_tpg,
+	.fabric_drop_tpg		= tcm_mvsas_tgt_drop_tpg,
+	.fabric_post_link		= NULL,
+	.fabric_pre_unlink		= NULL,
+	.fabric_make_np			= NULL,
+	.fabric_drop_np			= NULL,
+	.fabric_make_nodeacl		= tcm_mvsas_tgt_make_nodeacl,
+	.fabric_drop_nodeacl		= tcm_mvsas_tgt_drop_nodeacl,
+};
+
+static int tcm_mvsas_tgt_register_configfs(void)
+{
+	struct target_fabric_configfs *fabric;
+	int ret;
+
+	printk(KERN_INFO "TCM_MVSAS_TGT fabric module %s on %s/%s"
+		" on "UTS_RELEASE"\n",TCM_MVSAS_TGT_VERSION, utsname()->sysname,
+		utsname()->machine);
+	/*
+	 * Register the top level struct config_item_type with TCM core
+	 */
+	fabric = target_fabric_configfs_init(THIS_MODULE, "mvsas_tgt");
+	if (!(fabric)) {
+		printk(KERN_ERR "target_fabric_configfs_init() failed\n");
+		return -ENOMEM;
+	}
+	/*
+	 * Setup fabric->tf_ops from our local tcm_mvsas_tgt_ops
+	 */
+	fabric->tf_ops = tcm_mvsas_tgt_ops;
+	/*
+	 * Setup default attribute lists for various fabric->tf_cit_tmpl
+	 */
+	TF_CIT_TMPL(fabric)->tfc_wwn_cit.ct_attrs = tcm_mvsas_tgt_wwn_attrs;
+	TF_CIT_TMPL(fabric)->tfc_tpg_base_cit.ct_attrs = NULL;
+	TF_CIT_TMPL(fabric)->tfc_tpg_attrib_cit.ct_attrs = NULL;
+	TF_CIT_TMPL(fabric)->tfc_tpg_param_cit.ct_attrs = NULL;
+	TF_CIT_TMPL(fabric)->tfc_tpg_np_base_cit.ct_attrs = NULL;
+	TF_CIT_TMPL(fabric)->tfc_tpg_nacl_base_cit.ct_attrs = NULL;
+	TF_CIT_TMPL(fabric)->tfc_tpg_nacl_attrib_cit.ct_attrs = NULL;
+	TF_CIT_TMPL(fabric)->tfc_tpg_nacl_auth_cit.ct_attrs = NULL;
+	TF_CIT_TMPL(fabric)->tfc_tpg_nacl_param_cit.ct_attrs = NULL;
+	/*
+	 * Register the fabric for use within TCM
+	 */
+	ret = target_fabric_configfs_register(fabric);
+	if (ret < 0) {
+		printk(KERN_ERR "target_fabric_configfs_register() failed"
+				" for TCM_MVSAS_TGT\n");
+		return ret;
+	}
+	/*
+	 * Setup our local pointer to *fabric
+	 */
+	tcm_mvsas_tgt_fabric_configfs = fabric;
+	printk(KERN_INFO "TCM_MVSAS_TGT[0] - Set fabric ->
tcm_mvsas_tgt_fabric_configfs\n");
+	return 0;
+};
+
+static void tcm_mvsas_tgt_deregister_configfs(void)
+{
+	if (!(tcm_mvsas_tgt_fabric_configfs))
+		return;
+
+	target_fabric_configfs_deregister(tcm_mvsas_tgt_fabric_configfs);
+	tcm_mvsas_tgt_fabric_configfs = NULL;
+	printk(KERN_INFO "TCM_MVSAS_TGT[0] - Cleared
tcm_mvsas_tgt_fabric_configfs\n");
+};
+
+static int __init tcm_mvsas_tgt_init(void)
+{
+	int ret;
+
+	ret = tcm_mvsas_tgt_register_configfs();
+	if (ret < 0)
+		return ret;
+
+	return 0;
+};
+
+static void tcm_mvsas_tgt_exit(void)
+{
+	tcm_mvsas_tgt_deregister_configfs();
+};
+
+#ifdef MODULE
+MODULE_DESCRIPTION("TCM_MVSAS_TGT series fabric driver");
+MODULE_LICENSE("GPL");
+module_init(tcm_mvsas_tgt_init);
+module_exit(tcm_mvsas_tgt_exit);
+#endif
diff --git a/drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.c
b/drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.c
new file mode 100644
index 0000000..36c92cc
--- /dev/null
+++ b/drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.c
@@ -0,0 +1,272 @@
+#include <linux/slab.h>
+#include <linux/kthread.h>
+#include <linux/types.h>
+#include <linux/list.h>
+#include <linux/types.h>
+#include <linux/string.h>
+#include <linux/ctype.h>
+#include <asm/unaligned.h>
+#include <scsi/scsi.h>
+#include <scsi/scsi_host.h>
+#include <scsi/scsi_device.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/libfc.h>
+
+#include <target/target_core_base.h>
+#include <target/target_core_transport.h>
+#include <target/target_core_fabric_ops.h>
+#include <target/target_core_fabric_lib.h>
+#include <target/target_core_device.h>
+#include <target/target_core_tpg.h>
+#include <target/target_core_configfs.h>
+#include <tcm_mvsas_tgt_base.h>
+#include <tcm_mvsas_tgt_fabric.h>
+
+int tcm_mvsas_tgt_check_true(struct se_portal_group *se_tpg)
+{
+	return 1;
+}
+
+int tcm_mvsas_tgt_check_false(struct se_portal_group *se_tpg)
+{
+	return 0;
+}
+
+char *tcm_mvsas_tgt_get_fabric_name(void)
+{
+	return "mvsas_tgt";
+}
+
+u8 tcm_mvsas_tgt_get_fabric_proto_ident(struct se_portal_group *se_tpg)
+{
+	struct tcm_mvsas_tgt_tpg *tpg = container_of(se_tpg,
+				struct tcm_mvsas_tgt_tpg, se_tpg);
+	struct tcm_mvsas_tgt_tport *tport = tpg->tport;
+	u8 proto_id;
+
+	switch (tport->tport_proto_id) {
+	case SCSI_PROTOCOL_SAS:
+	default:
+		proto_id = sas_get_fabric_proto_ident(se_tpg);
+		break;
+	}
+
+	return proto_id;
+}
+
+char *tcm_mvsas_tgt_get_fabric_wwn(struct se_portal_group *se_tpg)
+{
+	struct tcm_mvsas_tgt_tpg *tpg = container_of(se_tpg,
+				struct tcm_mvsas_tgt_tpg, se_tpg);
+	struct tcm_mvsas_tgt_tport *tport = tpg->tport;
+
+	return &tport->tport_name[0];
+}
+
+u16 tcm_mvsas_tgt_get_tag(struct se_portal_group *se_tpg)
+{
+	struct tcm_mvsas_tgt_tpg *tpg = container_of(se_tpg,
+				struct tcm_mvsas_tgt_tpg, se_tpg);
+	return tpg->tport_tpgt;
+}
+
+u32 tcm_mvsas_tgt_get_default_depth(struct se_portal_group *se_tpg)
+{
+	return 1;
+}
+
+u32 tcm_mvsas_tgt_get_pr_transport_id(
+	struct se_portal_group *se_tpg,
+	struct se_node_acl *se_nacl,
+	struct t10_pr_registration *pr_reg,
+	int *format_code,
+	unsigned char *buf)
+{
+	struct tcm_mvsas_tgt_tpg *tpg = container_of(se_tpg,
+				struct tcm_mvsas_tgt_tpg, se_tpg);
+	struct tcm_mvsas_tgt_tport *tport = tpg->tport;
+	int ret = 0;
+
+	switch (tport->tport_proto_id) {
+	case SCSI_PROTOCOL_SAS:
+	default:
+		ret = sas_get_pr_transport_id(se_tpg, se_nacl, pr_reg,
+					format_code, buf);
+		break;
+	}
+
+	return ret;
+}
+
+u32 tcm_mvsas_tgt_get_pr_transport_id_len(
+	struct se_portal_group *se_tpg,
+	struct se_node_acl *se_nacl,
+	struct t10_pr_registration *pr_reg,
+	int *format_code)
+{
+	struct tcm_mvsas_tgt_tpg *tpg = container_of(se_tpg,
+				struct tcm_mvsas_tgt_tpg, se_tpg);
+	struct tcm_mvsas_tgt_tport *tport = tpg->tport;
+	int ret = 0;
+
+	switch (tport->tport_proto_id) {
+	case SCSI_PROTOCOL_SAS:
+	default:
+		ret = sas_get_pr_transport_id_len(se_tpg, se_nacl, pr_reg,
+					format_code);
+		break;
+	}
+
+	return ret;
+}
+
+char *tcm_mvsas_tgt_parse_pr_out_transport_id(
+	struct se_portal_group *se_tpg,
+	const char *buf,
+	u32 *out_tid_len,
+	char **port_nexus_ptr)
+{
+	struct tcm_mvsas_tgt_tpg *tpg = container_of(se_tpg,
+				struct tcm_mvsas_tgt_tpg, se_tpg);
+	struct tcm_mvsas_tgt_tport *tport = tpg->tport;
+	char *tid = NULL;
+
+	switch (tport->tport_proto_id) {
+	case SCSI_PROTOCOL_SAS:
+	default:
+		tid = sas_parse_pr_out_transport_id(se_tpg, buf, out_tid_len,
+					port_nexus_ptr);
+	}
+
+	return tid;
+}
+
+struct se_node_acl *tcm_mvsas_tgt_alloc_fabric_acl(struct
se_portal_group *se_tpg)
+{
+	struct tcm_mvsas_tgt_nacl *nacl;
+
+	nacl = kzalloc(sizeof(struct tcm_mvsas_tgt_nacl), GFP_KERNEL);
+	if (!(nacl)) {
+		printk(KERN_ERR "Unable to alocate struct tcm_mvsas_tgt_nacl\n");
+		return NULL;
+	}
+
+	return &nacl->se_node_acl;
+}
+
+void tcm_mvsas_tgt_release_fabric_acl(
+	struct se_portal_group *se_tpg,
+	struct se_node_acl *se_nacl)
+{
+	struct tcm_mvsas_tgt_nacl *nacl = container_of(se_nacl,
+			struct tcm_mvsas_tgt_nacl, se_node_acl);
+	kfree(nacl);
+}
+
+u32 tcm_mvsas_tgt_tpg_get_inst_index(struct se_portal_group *se_tpg)
+{
+	return 1;
+}
+
+void tcm_mvsas_tgt_release_cmd(struct se_cmd *se_cmd)
+{
+	return;
+}
+
+int tcm_mvsas_tgt_shutdown_session(struct se_session *se_sess)
+{
+	return 0;
+}
+
+void tcm_mvsas_tgt_close_session(struct se_session *se_sess)
+{
+	return;
+}
+
+void tcm_mvsas_tgt_stop_session(struct se_session *se_sess, int
sess_sleep , int conn_sleep)
+{
+	return;
+}
+
+void tcm_mvsas_tgt_reset_nexus(struct se_session *se_sess)
+{
+	return;
+}
+
+int tcm_mvsas_tgt_sess_logged_in(struct se_session *se_sess)
+{
+	return 0;
+}
+
+u32 tcm_mvsas_tgt_sess_get_index(struct se_session *se_sess)
+{
+	return 0;
+}
+
+int tcm_mvsas_tgt_write_pending(struct se_cmd *se_cmd)
+{
+	return 0;
+}
+
+int tcm_mvsas_tgt_write_pending_status(struct se_cmd *se_cmd)
+{
+	return 0;
+}
+
+void tcm_mvsas_tgt_set_default_node_attrs(struct se_node_acl *nacl)
+{
+	return;
+}
+
+u32 tcm_mvsas_tgt_get_task_tag(struct se_cmd *se_cmd)
+{
+	return 0;
+}
+
+int tcm_mvsas_tgt_get_cmd_state(struct se_cmd *se_cmd)
+{
+	return 0;
+}
+
+void tcm_mvsas_tgt_new_cmd_failure(struct se_cmd *se_cmd)
+{
+	return;
+}
+
+int tcm_mvsas_tgt_queue_data_in(struct se_cmd *se_cmd)
+{
+	return 0;
+}
+
+int tcm_mvsas_tgt_queue_status(struct se_cmd *se_cmd)
+{
+	return 0;
+}
+
+int tcm_mvsas_tgt_queue_tm_rsp(struct se_cmd *se_cmd)
+{
+	return 0;
+}
+
+u16 tcm_mvsas_tgt_set_fabric_sense_len(struct se_cmd *se_cmd, u32 sense_length)
+{
+	return 0;
+}
+
+u16 tcm_mvsas_tgt_get_fabric_sense_len(void)
+{
+	return 0;
+}
+
+int tcm_mvsas_tgt_is_state_remove(struct se_cmd *se_cmd)
+{
+	return 0;
+}
+
+u64 tcm_mvsas_tgt_pack_lun(unsigned int lun)
+{
+	WARN_ON(lun >= 256);
+	/* Caller wants this byte-swapped */
+	return cpu_to_le64((lun & 0xff) << 8);
+}
+
diff --git a/drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.h
b/drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.h
new file mode 100644
index 0000000..fb1a021
--- /dev/null
+++ b/drivers/target/tcm_mvsas_tgt/tcm_mvsas_tgt_fabric.h
@@ -0,0 +1,39 @@
+int tcm_mvsas_tgt_check_true(struct se_portal_group *);
+int tcm_mvsas_tgt_check_false(struct se_portal_group *);
+char *tcm_mvsas_tgt_get_fabric_name(void);
+u8 tcm_mvsas_tgt_get_fabric_proto_ident(struct se_portal_group *);
+char *tcm_mvsas_tgt_get_fabric_wwn(struct se_portal_group *);
+u16 tcm_mvsas_tgt_get_tag(struct se_portal_group *);
+u32 tcm_mvsas_tgt_get_default_depth(struct se_portal_group *);
+u32 tcm_mvsas_tgt_get_pr_transport_id(struct se_portal_group *,
+			struct se_node_acl *, struct t10_pr_registration *,
+			int *, unsigned char *);
+u32 tcm_mvsas_tgt_get_pr_transport_id_len(struct se_portal_group *,
+			struct se_node_acl *, struct t10_pr_registration *,
+			int *);
+char *tcm_mvsas_tgt_parse_pr_out_transport_id(struct se_portal_group *,
+			const char *, u32 *, char **);
+struct se_node_acl *tcm_mvsas_tgt_alloc_fabric_acl(struct se_portal_group *);
+void tcm_mvsas_tgt_release_fabric_acl(struct se_portal_group *,
+			struct se_node_acl *);
+u32 tcm_mvsas_tgt_tpg_get_inst_index(struct se_portal_group *);
+void tcm_mvsas_tgt_release_cmd(struct se_cmd *);
+int tcm_mvsas_tgt_shutdown_session(struct se_session *);
+void tcm_mvsas_tgt_close_session(struct se_session *);
+void tcm_mvsas_tgt_stop_session(struct se_session *, int, int);
+void tcm_mvsas_tgt_reset_nexus(struct se_session *);
+int tcm_mvsas_tgt_sess_logged_in(struct se_session *);
+u32 tcm_mvsas_tgt_sess_get_index(struct se_session *);
+int tcm_mvsas_tgt_write_pending(struct se_cmd *);
+int tcm_mvsas_tgt_write_pending_status(struct se_cmd *);
+void tcm_mvsas_tgt_set_default_node_attrs(struct se_node_acl *);
+u32 tcm_mvsas_tgt_get_task_tag(struct se_cmd *);
+int tcm_mvsas_tgt_get_cmd_state(struct se_cmd *);
+void tcm_mvsas_tgt_new_cmd_failure(struct se_cmd *);
+int tcm_mvsas_tgt_queue_data_in(struct se_cmd *);
+int tcm_mvsas_tgt_queue_status(struct se_cmd *);
+int tcm_mvsas_tgt_queue_tm_rsp(struct se_cmd *);
+u16 tcm_mvsas_tgt_set_fabric_sense_len(struct se_cmd *, u32);
+u16 tcm_mvsas_tgt_get_fabric_sense_len(void);
+int tcm_mvsas_tgt_is_state_remove(struct se_cmd *);
+u64 tcm_mvsas_tgt_pack_lun(unsigned int);
-- 
1.7.1

^ permalink raw reply related

* Re: build failure of drivers/scsi/gdth.c
From: Randy Dunlap @ 2011-01-18 16:46 UTC (permalink / raw)
  To: Or Gerlitz; +Cc: Or Gerlitz, linux-scsi
In-Reply-To: <4D3543A6.8040909@voltaire.com>

On Tue, 18 Jan 2011 09:39:18 +0200 Or Gerlitz wrote:

> Randy Dunlap wrote:
> > It builds OK for me.
> 
> okay, maybe something else is broken on my build environment, I'll send
> you off list the compressed verbose build log, the problem I'm not spotting
> is why LINUX_VERSION_CODE is defined to nothing in my env. I'm hitting this
> error on drivers/scsi/gdth.c and some other code that look on that constant,
> luckily there aren't many drivers doing that...

Thanks for more data/details.  There was something similar to this reported
a few months ago, but nothing has been done about it.

What shell are you using?
Are you using any other build scripts that set an variable named VERSION ?


See https://bugzilla.kernel.org/show_bug.cgi?id=16510

An alternative to the current generated version.h file was also suggested:

echo "#define LINUX_VERSION_CODE KERNEL_VERSION($(VERSION), $(PATCHLEVEL),
$(SUBLEVEL))"


HTH.
---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

^ permalink raw reply

* Re: [PATCH v4 1/3] scsi: Detailed I/O errors
From: Hannes Reinecke @ 2011-01-18 12:01 UTC (permalink / raw)
  To: dgilbert; +Cc: James Bottomley, linux-scsi, jaxboe, michaelc, agk, Mike Snitzer
In-Reply-To: <4D357AA3.5070509@interlog.com>

On 01/18/2011 12:33 PM, Douglas Gilbert wrote:
> On 11-01-18 10:13 AM, Hannes Reinecke wrote:
>> Instead of just passing 'EIO' for any I/O error we should be
>> notifying the upper layers with more details about the cause
>> of this error.
>>
>> Update the possible I/O errors to:
>>
>> - ENOLINK: Link failure between host and target
>> - EIO: Retryable I/O error
>> - EREMOTEIO: Non-retryable I/O error
>> - EBADE: I/O error restricted to the I_T_L nexus
>>
>> 'Retryable' in this context means that an I/O error _might_ be
>> restricted to the I_T_L nexus (vulgo: path), so retrying on another
>> nexus / path might succeed.
>>
>> 'Non-retryable' in general refers to a target failure, so this
>> error will always be generated regardless of the I_T_L nexus
>> it was send on.
>>
>> I/O errors restricted to the I_T_L nexus might be retried
>> on another nexus / path, but they should _not_ be queued
>> if no paths are available.
> 
> Hannes,
> I don't know if it is applicable to this patch but with
> SAS when the uplink from an expander is being stressed
> (i.e. it temporarily doesn't have enough bandwidth) then
> a sense key of ABORTED COMMAND may be generated. In my
> experience retrying such a command succeeds.
> 
I guess this should be handled by scsi EH, as there
should be some sensible ASC/ASCQ values to go with
it.

This patchset is primarily for fixing up multipathing,
which has the habit of retrying failed I/Os on the
next path. For some errors this is just pointless
(eg MEDIUM ERROR), for some errors this is the desired
behaviour (namely transport errors), and for others
this is positively damaging (persistent reservation
failures).
Just plain EIO simply don't cover the whole range :-)

> 
> BTW might "vulgo" be "ergo" [Latin: therefore]?
> 
Nope. Correct etymology is from 'sermo vulgaris',
ie the language of the common people.
But maybe I should remove it for the next
round to avoid confusion.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Markus Rex, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [LSF/MM TOPIC][ATTEND] Discard support review/update and benchmark numbers
From: Lukas Czerner @ 2011-01-18 11:53 UTC (permalink / raw)
  To: lsf-pc; +Cc: linux-fsdevel, linux-scsi

Agenda topic proposal:
----------------------

In the past year a lot of work has been done towards more efficient
Linux discard support. We would like to review all the efforts in
this area and summarize where we stand now and what can be done in
the near future. Show the options we have and how they perform with
various classes of devices in different benchmarks and present some
numbers. Last, but not least we think that we are at the point where
hardware vendors should join in the discussion. At this matter we
would like to outline the options they have to test the Linux discard
stack with their hardware and make it all cooperate easily.

Authors:
--------

Christoph Hellwig <hch@infradead.org>

Christoph Hellwig has been working with Linux for more than 10 years,
soon focussing on kernel-related issues. He has also been involved in
various other Free Software projects. After a number of smaller network
administration and programming contracts he worked for Caldera's German
development subsidiary on various kernel and userlevel aspects of the
OpenLinux distribution and later joined the filesystem and storage group
at SGI, focussing on XFS for Linux. Since 2004 he has been self-employed
doing contracting, consulting and training in the Linux Kernel and Storage
world.

Lukas Czerner <lczerner@redhat.com>

Lukas is a software engineer with Red Hat, Inc, where he works mainly on
Ext4 filesystem. He has been involved in performance evaluation of Linux
discard support and was examining of alternative approaches which led to
establishing the interface for filesystem batched discard support aka
FITRIM as well as implementation for Ext4/3 filesystems.


Thanks!
-Lukas

^ permalink raw reply

* Re: [PATCH v4 1/3] scsi: Detailed I/O errors
From: Douglas Gilbert @ 2011-01-18 11:33 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: James Bottomley, linux-scsi, jaxboe, michaelc, agk, Mike Snitzer
In-Reply-To: <b6ba7efc491aec18cd501f73e2e6bbebc2e0727a.1295340405.git.hare@suse.de>

On 11-01-18 10:13 AM, Hannes Reinecke wrote:
> Instead of just passing 'EIO' for any I/O error we should be
> notifying the upper layers with more details about the cause
> of this error.
>
> Update the possible I/O errors to:
>
> - ENOLINK: Link failure between host and target
> - EIO: Retryable I/O error
> - EREMOTEIO: Non-retryable I/O error
> - EBADE: I/O error restricted to the I_T_L nexus
>
> 'Retryable' in this context means that an I/O error _might_ be
> restricted to the I_T_L nexus (vulgo: path), so retrying on another
> nexus / path might succeed.
>
> 'Non-retryable' in general refers to a target failure, so this
> error will always be generated regardless of the I_T_L nexus
> it was send on.
>
> I/O errors restricted to the I_T_L nexus might be retried
> on another nexus / path, but they should _not_ be queued
> if no paths are available.

Hannes,
I don't know if it is applicable to this patch but with
SAS when the uplink from an expander is being stressed
(i.e. it temporarily doesn't have enough bandwidth) then
a sense key of ABORTED COMMAND may be generated. In my
experience retrying such a command succeeds.


BTW might "vulgo" be "ergo" [Latin: therefore]?

Doug Gilbert

^ permalink raw reply

* [PATCH v4 3/3] block: improve detail in I/O error messages
From: Hannes Reinecke @ 2011-01-18  9:13 UTC (permalink / raw)
  To: James Bottomley
  Cc: linux-scsi, jaxboe, michaelc, agk, Hannes Reinecke, Mike Snitzer
In-Reply-To: <cover.1295340405.git.hare@suse.de>

Classify severity of I/O errors for target, nexus, and
transport errors.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 block/blk-core.c |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 4ce953f..3380a49 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -2028,9 +2028,26 @@ bool blk_update_request(struct request *req, int error, unsigned int nr_bytes)
 
 	if (error && req->cmd_type == REQ_TYPE_FS &&
 	    !(req->cmd_flags & REQ_QUIET)) {
-		printk(KERN_ERR "end_request: I/O error, dev %s, sector %llu\n",
-				req->rq_disk ? req->rq_disk->disk_name : "?",
-				(unsigned long long)blk_rq_pos(req));
+		char *error_type;
+
+		switch (error) {
+		case -ENOLINK:
+			error_type = "recoverable transport";
+			break;
+		case -EREMOTEIO:
+			error_type = "critical target";
+			break;
+		case -EBADE:
+			error_type = "critical nexus";
+			break;
+		case -EIO:
+		default:
+			error_type = "I/O";
+			break;
+		}
+		printk(KERN_ERR "end_request: %s error, dev %s, sector %llu\n",
+		       error_type, req->rq_disk ? req->rq_disk->disk_name : "?",
+		       (unsigned long long)blk_rq_pos(req));
 	}
 
 	blk_account_io_completion(req, nr_bytes);
-- 
1.6.0.2


^ permalink raw reply related

* [PATCH v4 2/3] dm mpath: propagate target errors immediately
From: Hannes Reinecke @ 2011-01-18  9:13 UTC (permalink / raw)
  To: James Bottomley
  Cc: linux-scsi, jaxboe, michaelc, agk, Hannes Reinecke, Mike Snitzer
In-Reply-To: <cover.1295340405.git.hare@suse.de>

DM now has more information about the nature of the underlying storage
failure.  Path failure is avoided if a request failed due to a target
error.  Instead the target error is immediately passed up the stack.

Discard requests that fail due to non-target errors may now be retried.

Errors restricted to the path will be retried or returned if no
paths are available, irregarding the no_path_retry setting.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/md/dm-mpath.c |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index 487ecda..0781683 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -1270,24 +1270,22 @@ static int do_end_io(struct multipath *m, struct request *clone,
 	if (!error && !clone->errors)
 		return 0;	/* I/O complete */
 
-	if (error == -EOPNOTSUPP)
-		return error;
-
-	if (clone->cmd_flags & REQ_DISCARD)
-		/*
-		 * Pass all discard request failures up.
-		 * FIXME: only fail_path if the discard failed due to a
-		 * transport problem.  This requires precise understanding
-		 * of the underlying failure (e.g. the SCSI sense).
-		 */
+	if (error == -EOPNOTSUPP || error == -EREMOTEIO)
 		return error;
 
 	if (mpio->pgpath)
 		fail_path(mpio->pgpath);
 
 	spin_lock_irqsave(&m->lock, flags);
-	if (!m->nr_valid_paths && !m->queue_if_no_path && !__must_push_back(m))
-		r = -EIO;
+	if (!m->nr_valid_paths) {
+		if (!m->queue_if_no_path) {
+			if (!__must_push_back(m))
+				r = -EIO;
+		} else {
+			if (error == -EBADE)
+				r = error;
+		}
+	}
 	spin_unlock_irqrestore(&m->lock, flags);
 
 	return r;
-- 
1.6.0.2


^ permalink raw reply related

* [PATCH v4 1/3] scsi: Detailed I/O errors
From: Hannes Reinecke @ 2011-01-18  9:13 UTC (permalink / raw)
  To: James Bottomley
  Cc: linux-scsi, jaxboe, michaelc, agk, Hannes Reinecke, Mike Snitzer
In-Reply-To: <cover.1295340405.git.hare@suse.de>

Instead of just passing 'EIO' for any I/O error we should be
notifying the upper layers with more details about the cause
of this error.

Update the possible I/O errors to:

- ENOLINK: Link failure between host and target
- EIO: Retryable I/O error
- EREMOTEIO: Non-retryable I/O error
- EBADE: I/O error restricted to the I_T_L nexus

'Retryable' in this context means that an I/O error _might_ be
restricted to the I_T_L nexus (vulgo: path), so retrying on another
nexus / path might succeed.

'Non-retryable' in general refers to a target failure, so this
error will always be generated regardless of the I_T_L nexus
it was send on.

I/O errors restricted to the I_T_L nexus might be retried
on another nexus / path, but they should _not_ be queued
if no paths are available.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
---
 drivers/scsi/scsi_error.c |   24 +++++++++++++++++-------
 drivers/scsi/scsi_lib.c   |   28 ++++++++++++++++++++++++++--
 include/scsi/scsi.h       |    5 +++++
 3 files changed, 48 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 45c7564..991de3c 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -223,7 +223,7 @@ static inline void scsi_eh_prt_fail_stats(struct Scsi_Host *shost,
  * @scmd:	Cmd to have sense checked.
  *
  * Return value:
- * 	SUCCESS or FAILED or NEEDS_RETRY
+ *	SUCCESS or FAILED or NEEDS_RETRY or TARGET_ERROR
  *
  * Notes:
  *	When a deferred error is detected the current command has
@@ -326,17 +326,19 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
 		 */
 		return SUCCESS;
 
-		/* these three are not supported */
+		/* these are not supported */
 	case COPY_ABORTED:
 	case VOLUME_OVERFLOW:
 	case MISCOMPARE:
-		return SUCCESS;
+	case BLANK_CHECK:
+	case DATA_PROTECT:
+		return TARGET_ERROR;
 
 	case MEDIUM_ERROR:
 		if (sshdr.asc == 0x11 || /* UNRECOVERED READ ERR */
 		    sshdr.asc == 0x13 || /* AMNF DATA FIELD */
 		    sshdr.asc == 0x14) { /* RECORD NOT FOUND */
-			return SUCCESS;
+			return TARGET_ERROR;
 		}
 		return NEEDS_RETRY;
 
@@ -344,11 +346,9 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
 		if (scmd->device->retry_hwerror)
 			return ADD_TO_MLQUEUE;
 		else
-			return SUCCESS;
+			return TARGET_ERROR;
 
 	case ILLEGAL_REQUEST:
-	case BLANK_CHECK:
-	case DATA_PROTECT:
 	default:
 		return SUCCESS;
 	}
@@ -787,6 +787,7 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,
 		case SUCCESS:
 		case NEEDS_RETRY:
 		case FAILED:
+		case TARGET_ERROR:
 			break;
 		case ADD_TO_MLQUEUE:
 			rtn = NEEDS_RETRY;
@@ -1469,6 +1470,14 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 		rtn = scsi_check_sense(scmd);
 		if (rtn == NEEDS_RETRY)
 			goto maybe_retry;
+		else if (rtn == TARGET_ERROR) {
+			/*
+			 * Need to modify host byte to signal a
+			 * permanent target failure
+			 */
+			scmd->result |= (DID_TARGET_FAILURE << 16);
+			rtn = SUCCESS;
+		}
 		/* if rtn == FAILED, we have no sense information;
 		 * returning FAILED will wake the error handler thread
 		 * to collect the sense and redo the decide
@@ -1486,6 +1495,7 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 	case RESERVATION_CONFLICT:
 		sdev_printk(KERN_INFO, scmd->device,
 			    "reservation conflict\n");
+		scmd->result |= (DID_NEXUS_FAILURE << 16);
 		return SUCCESS; /* causes immediate i/o error */
 	default:
 		return FAILED;
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 0ed7a66..91f1c13 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -667,6 +667,30 @@ void scsi_release_buffers(struct scsi_cmnd *cmd)
 }
 EXPORT_SYMBOL(scsi_release_buffers);
 
+static int __scsi_error_from_host_byte(struct scsi_cmnd *cmd, int result)
+{
+	int error = 0;
+
+	switch(host_byte(result)) {
+	case DID_TRANSPORT_FAILFAST:
+		error = -ENOLINK;
+		break;
+	case DID_TARGET_FAILURE:
+		cmd->result |= (DID_OK << 16);
+		error = -EREMOTEIO;
+		break;
+	case DID_NEXUS_FAILURE:
+		cmd->result |= (DID_OK << 16);
+		error = -EBADE;
+		break;
+	default:
+		error = -EIO;
+		break;
+	}
+
+	return error;
+}
+
 /*
  * Function:    scsi_io_completion()
  *
@@ -737,7 +761,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
 				req->sense_len = len;
 			}
 			if (!sense_deferred)
-				error = -EIO;
+				error = __scsi_error_from_host_byte(cmd, result);
 		}
 
 		req->resid_len = scsi_get_resid(cmd);
@@ -796,7 +820,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
 	if (scsi_end_request(cmd, error, good_bytes, result == 0) == NULL)
 		return;
 
-	error = -EIO;
+	error = __scsi_error_from_host_byte(cmd, result);
 
 	if (host_byte(result) == DID_RESET) {
 		/* Third party bus reset or reset for error recovery
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index 1651fef..078a0ac 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -433,6 +433,10 @@ static inline int scsi_is_wlun(unsigned int lun)
 				      * recover the link. Transport class will
 				      * retry or fail IO */
 #define DID_TRANSPORT_FAILFAST	0x0f /* Transport class fastfailed the io */
+#define DID_TARGET_FAILURE 0x10 /* Permanent target failure, do not retry on
+				 * other paths */
+#define DID_NEXUS_FAILURE 0x11  /* Permanent nexus failure, retry on other
+				 * paths might yield different results */
 #define DRIVER_OK       0x00	/* Driver status                           */
 
 /*
@@ -462,6 +466,7 @@ static inline int scsi_is_wlun(unsigned int lun)
 #define TIMEOUT_ERROR   0x2007
 #define SCSI_RETURN_NOT_HANDLED   0x2008
 #define FAST_IO_FAIL	0x2009
+#define TARGET_ERROR    0x200A
 
 /*
  * Midlevel queue return values.
-- 
1.6.0.2


^ permalink raw reply related

* [PATCH v4 0/3] differentiate between I/O errors
From: Hannes Reinecke @ 2011-01-18  9:13 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-scsi, jaxboe, michaelc, agk, Hannes Reinecke

Changes in v4:
Included new error -EBADE to signal nexus errors.

The diffstat:

Hannes Reinecke (1):
  scsi: Detailed I/O errors

Mike Snitzer (2):
  dm mpath: propagate target errors immediately
  block: improve detail in I/O error messages

 block/blk-core.c          |   23 ++++++++++++++++++++---
 drivers/md/dm-mpath.c     |   22 ++++++++++------------
 drivers/scsi/scsi_error.c |   24 +++++++++++++++++-------
 drivers/scsi/scsi_lib.c   |   28 ++++++++++++++++++++++++++--
 include/scsi/scsi.h       |    5 +++++
 5 files changed, 78 insertions(+), 24 deletions(-)


^ permalink raw reply

* Re: build failure of drivers/scsi/gdth.c
From: Or Gerlitz @ 2011-01-18  7:39 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: Or Gerlitz, linux-scsi
In-Reply-To: <20110113091127.dcdd3105.rdunlap@xenotime.net>

Randy Dunlap wrote:
> It builds OK for me.

okay, maybe something else is broken on my build environment, I'll send
you off list the compressed verbose build log, the problem I'm not spotting
is why LINUX_VERSION_CODE is defined to nothing in my env. I'm hitting this
error on drivers/scsi/gdth.c and some other code that look on that constant,
luckily there aren't many drivers doing that...

Or.

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox